purge();
} else {
FD_SET(c->socket, readset);
- if(c->outbuflen > 0)
+ if(c->outbuflen > 0 || c->status.connecting)
FD_SET(c->socket, writeset);
if(c->socket > max)
max = c->socket;
c->status.remove = false;
do_outgoing_connection(c);
}
+
+#ifndef HAVE_MINGW
+ /* Clean up dead proxy processes */
+
+ while(waitpid(-1, NULL, WNOHANG) > 0);
+#endif
}
/*
if(c->status.remove)
continue;
- if(FD_ISSET(c->socket, readset)) {
+ if(FD_ISSET(c->socket, writeset)) {
if(c->status.connecting) {
c->status.connecting = false;
getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len);
}
}
- if(!receive_meta(c)) {
+ if(!flush_meta(c)) {
terminate_connection(c, c->status.active);
continue;
}
}
- if(FD_ISSET(c->socket, writeset)) {
- if(!flush_meta(c)) {
+ if(FD_ISSET(c->socket, readset)) {
+ if(!receive_meta(c)) {
terminate_connection(c, c->status.active);
continue;
}
expire_events();
for(node = connection_tree->head; node; node = node->next) {
connection_t *c = node->data;
- send_ping(c);
+ if(c->status.active)
+ send_ping(c);
}
sigalrm = false;
}