]> git.ozlabs.org Git - ccan/blobdiff - ccan/net/net.c
To compile ccan under DragonFly BSD some additional includes are required.
[ccan] / ccan / net / net.c
index 82d6c4e54bd82e2c02415cb6cd7ebcf721f49659..816c8eef98872a71b8a9a54d9e83de4e896dcd0f 100644 (file)
@@ -1,5 +1,4 @@
 #include <ccan/net/net.h>
-#include <ccan/noerr/noerr.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <poll.h>
@@ -10,6 +9,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <stdbool.h>
+#include <netinet/in.h>
 
 struct addrinfo *net_client_lookup(const char *hostname,
                                   const char *service,
@@ -64,7 +64,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 +142,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;
 }