From 7df18f17d159a5f410ff2f1395198a3496a80fd4 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 1 Sep 2013 11:43:10 +0200 Subject: [PATCH] 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. --- src/net.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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; } -- 2.20.1