summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2014-05-27 13:17:29 +0930
committerRusty Russell <rusty@rustcorp.com.au>2014-05-27 13:17:29 +0930
commit77354575335e5ee900a4ba126d4d76e34b9273e8 (patch)
treebc7cbe13fdbf17aef9433aafb9ba9ad136f4e603
parentebc67c3fc630b8c7e71880c4972f5f8cde3b9a53 (diff)
net: don't return still-connecting fd.
If one connect failed, we'd return the other one without waiting for the connect to complete. This resulted in read() returning 0, which was really weird. The downside: the poll doesn't seem to time out when the connect times out (Linux 3.13 x86-64). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--ccan/net/net.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ccan/net/net.c b/ccan/net/net.c
index 4c84ba7a..7867054d 100644
--- a/ccan/net/net.c
+++ b/ccan/net/net.c
@@ -159,6 +159,9 @@ int net_connect_complete(struct pollfd pfds[2])
}
continue;
}
+ if (!(pfds[i].revents & POLLOUT))
+ continue;
+
if (getsockopt(pfds[i].fd, SOL_SOCKET, SO_ERROR, &err,
&errlen) != 0) {
net_connect_abort(pfds);