From: Guus Sliepen Date: Sun, 1 Sep 2013 09:43:10 +0000 (+0200) Subject: Check for writability when waiting for a socket to finish connecting. X-Git-Tag: release-1.0.23~8 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=7df18f17d159a5f410ff2f1395198a3496a80fd4;p=tinc Check for writability when waiting for a socket to finish connecting. This causes daemons that make an outgoing connection to immediately send the ID message (or proxy handshake), as intended. --- diff --git a/src/net.c b/src/net.c index 9799feab..e5ffc4f5 100644 --- a/src/net.c +++ b/src/net.c @@ -134,7 +134,7 @@ static int build_fdset(fd_set *readset, fd_set *writeset) { 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; @@ -308,7 +308,7 @@ static void check_network_activity(fd_set * readset, fd_set * writeset) { 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); @@ -325,14 +325,14 @@ static void check_network_activity(fd_set * readset, fd_set * writeset) { } } - 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; }