X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fnet%2Fnet.c;h=61efd5b8fd4b55643b157d3cf90e73818b2a20f4;hb=52132f298730837e8d62adb8b6b6b9c9d3aca82a;hp=394c4e49f2bb16024ea576b0aa68ed1376c25bcc;hpb=fc8acdbbe2484794aa3c3bea8c00f0de80e48811;p=ccan diff --git a/ccan/net/net.c b/ccan/net/net.c index 394c4e49..61efd5b8 100644 --- a/ccan/net/net.c +++ b/ccan/net/net.c @@ -1,10 +1,7 @@ /* Licensed under BSD-MIT - see LICENSE file for details */ #include #include -#include -#include #include -#include #include #include #include @@ -116,7 +113,7 @@ int net_connect_async(const struct addrinfo *addrinfo, struct pollfd pfds[2]) close_noerr(pfds[i].fd); return -1; } - return pfds[0].fd; + return pfds[i].fd; } } @@ -159,6 +156,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);