From 761460886aea8c09db87e26c7656ee0ba26a5017 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Tue, 1 Mar 2016 20:17:58 -0800 Subject: [PATCH] Sync with upstream --- adsbus/asyncaddrinfo.c | 5 +++-- adsbus/asyncaddrinfo.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/adsbus/asyncaddrinfo.c b/adsbus/asyncaddrinfo.c index 74edf69..c2578c4 100644 --- a/adsbus/asyncaddrinfo.c +++ b/adsbus/asyncaddrinfo.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -65,7 +66,7 @@ void asyncaddrinfo_init(size_t threads) { assert(asyncaddrinfo_threads); for (size_t i = 0; i < asyncaddrinfo_num_threads; i++) { - int subfd = dup(fds[0]); + int subfd = fcntl(fds[0], F_DUPFD_CLOEXEC, 0); assert(subfd >= 0); assert(!pthread_create(&asyncaddrinfo_threads[i], NULL, asyncaddrinfo_main, (void *) (intptr_t) subfd)); } @@ -83,7 +84,7 @@ void asyncaddrinfo_cleanup() { asyncaddrinfo_threads = NULL; } -int asyncaddrinfo_resolve(const char *node, const char *service, struct addrinfo *hints) { +int asyncaddrinfo_resolve(const char *node, const char *service, const struct addrinfo *hints) { int fds[2]; assert(!socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, fds)); diff --git a/adsbus/asyncaddrinfo.h b/adsbus/asyncaddrinfo.h index a0a7ef6..bd42d09 100644 --- a/adsbus/asyncaddrinfo.h +++ b/adsbus/asyncaddrinfo.h @@ -4,5 +4,5 @@ struct addrinfo; void asyncaddrinfo_init(size_t threads); void asyncaddrinfo_cleanup(void); -int asyncaddrinfo_resolve(const char *node, const char *service, struct addrinfo *hints); +int asyncaddrinfo_resolve(const char *node, const char *service, const struct addrinfo *hints); int asyncaddrinfo_result(int fd, struct addrinfo **addrs);