X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fnet%2Fnet.c;h=30f6560ea29a6423be34e4e04373857eb6dcf88e;hp=82d6c4e54bd82e2c02415cb6cd7ebcf721f49659;hb=8458811a4126c22635b974718bfbf2876c893c37;hpb=04a42d50a02645aca83d7dc02d8e9838540e818d;ds=sidebyside diff --git a/ccan/net/net.c b/ccan/net/net.c index 82d6c4e5..30f6560e 100644 --- a/ccan/net/net.c +++ b/ccan/net/net.c @@ -1,5 +1,5 @@ +/* Licensed under BSD-MIT - see LICENSE file for details */ #include -#include #include #include #include @@ -10,6 +10,7 @@ #include #include #include +#include struct addrinfo *net_client_lookup(const char *hostname, const char *service, @@ -64,7 +65,7 @@ static void remove_fd(struct pollfd pfd[], int net_connect(const struct addrinfo *addrinfo) { - int sockfd = -1; + int sockfd = -1, saved_errno; unsigned int i, num; const struct addrinfo *ipv4 = NULL, *ipv6 = NULL; const struct addrinfo *addr[MAX_PROTOS]; @@ -142,8 +143,10 @@ got_one: sockfd = pfd[i].fd; out: + saved_errno = errno; for (i = 0; i < num; i++) if (pfd[i].fd != sockfd) - close_noerr(pfd[i].fd); + close(pfd[i].fd); + errno = saved_errno; return sockfd; }