#include "subnet.h"
#include "xalloc.h"
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+
bool do_purge = false;
volatile bool running = false;
#ifdef HAVE_PSELECT
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;
closesocket(c->socket);
if(c->edge) {
+ if(!c->node) {
+ logger(LOG_ERR, "Connection to %s (%s) has an edge but node is NULL!", c->name, c->hostname);
+ // And that should never happen.
+ abort();
+ }
+
if(report && !tunnelserver)
send_del_edge(everyone, c->edge);
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;
}
avl_node_t *node;
logger(LOG_INFO, "Flushing event queue");
expire_events();
+#ifdef HAVE_DECL_RES_INIT
+ res_init();
+#endif
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;
}