diff options
Diffstat (limited to 'poll')
-rw-r--r-- | poll/unix/epoll.c | 35 | ||||
-rw-r--r-- | poll/unix/kqueue.c | 25 | ||||
-rw-r--r-- | poll/unix/port.c | 23 |
3 files changed, 82 insertions, 1 deletions
diff --git a/poll/unix/epoll.c b/poll/unix/epoll.c index c8ab6d63a..0c5fa8f67 100644 --- a/poll/unix/epoll.c +++ b/poll/unix/epoll.c @@ -15,6 +15,7 @@ */ #include "apr_arch_poll_private.h" +#include "apr_arch_inherit.h" #ifdef POLLSET_USES_EPOLL @@ -147,12 +148,29 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, /* Add room for wakeup descriptor */ size++; } +#ifdef HAVE_EPOLL_CREATE1 + fd = epoll_create1(EPOLL_CLOEXEC); +#else fd = epoll_create(size); +#endif if (fd < 0) { *pollset = NULL; return errno; } +#ifndef HAVE_EPOLL_CREATE1 + { + int flags; + + if ((flags = fcntl(fd, F_GETFD)) == -1) + return errno; + + flags |= FD_CLOEXEC; + if (fcntl(fd, F_SETFD, flags) == -1) + return errno; + } +#endif + *pollset = apr_palloc(p, sizeof(**pollset)); #if APR_HAS_THREADS if ((flags & APR_POLLSET_THREADSAFE) && @@ -413,12 +431,29 @@ APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb, { int fd; +#ifdef HAVE_EPOLL_CREATE1 + fd = epoll_create1(EPOLL_CLOEXEC); +#else fd = epoll_create(size); +#endif if (fd < 0) { *pollcb = NULL; return apr_get_netos_error(); } + +#ifndef HAVE_EPOLL_CREATE1 + { + int flags; + + if ((flags = fcntl(fd, F_GETFD)) == -1) + return errno; + + flags |= FD_CLOEXEC; + if (fcntl(fd, F_SETFD, flags) == -1) + return errno; + } +#endif *pollcb = apr_palloc(p, sizeof(**pollcb)); (*pollcb)->nalloc = size; diff --git a/poll/unix/kqueue.c b/poll/unix/kqueue.c index 406eba6e9..34ec1dd42 100644 --- a/poll/unix/kqueue.c +++ b/poll/unix/kqueue.c @@ -15,6 +15,7 @@ */ #include "apr_arch_poll_private.h" +#include "apr_arch_inherit.h" #ifdef POLLSET_USES_KQUEUE @@ -156,6 +157,17 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return apr_get_netos_error(); } + { + int flags; + + if ((flags = fcntl((*pollset)->kqueue_fd, F_GETFD)) == -1) + return errno; + + flags |= FD_CLOEXEC; + if (fcntl((*pollset)->kqueue_fd, F_SETFD, flags) == -1) + return errno; + } + (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); APR_RING_INIT(&(*pollset)->query_ring, pfd_elem_t, link); @@ -389,7 +401,18 @@ APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb, *pollcb = NULL; return apr_get_netos_error(); } - + + { + int flags; + + if ((flags = fcntl(fd, F_GETFD)) == -1) + return errno; + + flags |= FD_CLOEXEC; + if (fcntl(fd, F_SETFD, flags) == -1) + return errno; + } + *pollcb = apr_palloc(p, sizeof(**pollcb)); (*pollcb)->nalloc = size; (*pollcb)->pool = p; diff --git a/poll/unix/port.c b/poll/unix/port.c index 73d852511..ab45b9913 100644 --- a/poll/unix/port.c +++ b/poll/unix/port.c @@ -16,6 +16,7 @@ #include "apr_arch_poll_private.h" #include "apr_atomic.h" +#include "apr_arch_inherit.h" #ifdef POLLSET_USES_PORT @@ -181,6 +182,17 @@ APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, return APR_ENOMEM; } + { + int flags; + + if ((flags = fcntl((*pollset)->port_fd, F_GETFD)) == -1) + return errno; + + flags |= FD_CLOEXEC; + if (fcntl((*pollset)->port_fd, F_SETFD, flags) == -1) + return errno; + } + (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t)); APR_RING_INIT(&(*pollset)->query_ring, pfd_elem_t, link); @@ -474,6 +486,17 @@ APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb, return apr_get_netos_error(); } + { + int flags; + + if ((flags = fcntl(fd, F_GETFD)) == -1) + return errno; + + flags |= FD_CLOEXEC; + if (fcntl(fd, F_SETFD, flags) == -1) + return errno; + } + *pollcb = apr_palloc(p, sizeof(**pollcb)); (*pollcb)->nalloc = size; (*pollcb)->pool = p; |