summaryrefslogtreecommitdiff
path: root/poll/unix/kqueue.c
diff options
context:
space:
mode:
Diffstat (limited to 'poll/unix/kqueue.c')
-rw-r--r--poll/unix/kqueue.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/poll/unix/kqueue.c b/poll/unix/kqueue.c
index 2e25c9fde..355ccba99 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;