X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet.c;h=3eec9a647b5e3b2e77116323b05637b5dcdab8cf;hb=708825e4b229a4a1e182e682e2d1021fa2765396;hp=39b467df7bccf11ed79a36e1998cf485b90881a2;hpb=965710e7337523fc8605310d74c6f9240d76e7ce;p=tinc diff --git a/src/net.c b/src/net.c index 39b467df..3eec9a64 100644 --- a/src/net.c +++ b/src/net.c @@ -38,6 +38,7 @@ int contradicting_add_edge = 0; int contradicting_del_edge = 0; +bool running = true; /* Purge edges and subnets of unreachable nodes. Use carefully. */ @@ -220,14 +221,18 @@ void handle_meta_connection_data(void *data) { getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len); - if(!result) + if(!result) { + mutex_lock(&mutex); finish_connecting(c); - else { + mutex_unlock(&mutex); + } else { ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Error while connecting to %s (%s): %s", c->name, c->hostname, sockstrerror(result)); closesocket(c->socket); + mutex_lock(&mutex); do_outgoing_connection(c); + mutex_unlock(&mutex); return; } } @@ -235,21 +240,11 @@ void handle_meta_connection_data(void *data) { while(true) { if (!receive_meta(c)) { terminate_connection(c, c->status.active); - return; + break; } } } -static void sigterm_handler(int signal, short events, void *data) { - logger(LOG_NOTICE, "Got %s signal", strsignal(signal)); - exit(0); -} - -static void sighup_handler(int signal, short events, void *data) { - logger(LOG_NOTICE, "Got %s signal", strsignal(signal)); - reload_configuration(); -} - int reload_configuration(void) { connection_t *c; splay_node_t *node, *next; @@ -357,18 +352,12 @@ int main_loop(void) { event_add(&timeout_event); -#ifdef SIGHUP - signal(SIGHUP, sighup_handler); -#endif -#ifdef SIGTERM - signal(SIGTERM, sigterm_handler); -#endif -#ifdef SIGQUIT - signal(SIGQUIT, sigterm_handler); -#endif while(true) { - usleep(1000); + mutex_unlock(&mutex); + usleep(1000000); + mutex_lock(&mutex); + struct event *event; while((event = get_expired_event())) { event->handler(event->data);