X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet.c;h=2ffe03a7b39a7985fdb01a7ab1108880a62c0184;hp=39b467df7bccf11ed79a36e1998cf485b90881a2;hb=6834b882015a9323672e9fce8811aa4283f196f0;hpb=95d8811c2cef8bcde78e1f172f6c57c25cd487aa diff --git a/src/net.c b/src/net.c index 39b467df..2ffe03a7 100644 --- a/src/net.c +++ b/src/net.c @@ -220,14 +220,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,7 +239,7 @@ void handle_meta_connection_data(void *data) { while(true) { if (!receive_meta(c)) { terminate_connection(c, c->status.active); - return; + break; } } } @@ -368,7 +372,10 @@ int main_loop(void) { #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);