diff options
author | Peter Wemm <peter@FreeBSD.org> | 2015-08-09 04:32:54 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2015-08-09 04:32:54 +0000 |
commit | df84d2567179e9d8867957c089683d753016bd75 (patch) | |
tree | 22f2e9932cfc8bcfa6f728a311818f18a1f1d80d /poll/unix/kqueue.c | |
parent | bc9ddba9ef9abe23eadcdb51b2ce814c00c00639 (diff) |
Diffstat (limited to 'poll/unix/kqueue.c')
-rw-r--r-- | poll/unix/kqueue.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/poll/unix/kqueue.c b/poll/unix/kqueue.c index dbe785a1546e6..efc589869a698 100644 --- a/poll/unix/kqueue.c +++ b/poll/unix/kqueue.c @@ -115,12 +115,20 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset, { int flags; - if ((flags = fcntl(pollset->p->kqueue_fd, F_GETFD)) == -1) - return errno; + if ((flags = fcntl(pollset->p->kqueue_fd, F_GETFD)) == -1) { + rv = errno; + close(pollset->p->kqueue_fd); + pollset->p = NULL; + return rv; + } flags |= FD_CLOEXEC; - if (fcntl(pollset->p->kqueue_fd, F_SETFD, flags) == -1) - return errno; + if (fcntl(pollset->p->kqueue_fd, F_SETFD, flags) == -1) { + rv = errno; + close(pollset->p->kqueue_fd); + pollset->p = NULL; + return rv; + } } pollset->p->result_set = apr_palloc(p, pollset->p->setsize * sizeof(apr_pollfd_t)); @@ -338,13 +346,22 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb, { int flags; + apr_status_t rv; - if ((flags = fcntl(fd, F_GETFD)) == -1) - return errno; + if ((flags = fcntl(fd, F_GETFD)) == -1) { + rv = errno; + close(fd); + pollcb->fd = -1; + return rv; + } flags |= FD_CLOEXEC; - if (fcntl(fd, F_SETFD, flags) == -1) - return errno; + if (fcntl(fd, F_SETFD, flags) == -1) { + rv = errno; + close(fd); + pollcb->fd = -1; + return rv; + } } pollcb->fd = fd; |