summaryrefslogtreecommitdiff
path: root/poll/unix/epoll.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2015-08-09 04:32:54 +0000
committerPeter Wemm <peter@FreeBSD.org>2015-08-09 04:32:54 +0000
commitdf84d2567179e9d8867957c089683d753016bd75 (patch)
tree22f2e9932cfc8bcfa6f728a311818f18a1f1d80d /poll/unix/epoll.c
parentbc9ddba9ef9abe23eadcdb51b2ce814c00c00639 (diff)
Notes
Diffstat (limited to 'poll/unix/epoll.c')
-rw-r--r--poll/unix/epoll.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/poll/unix/epoll.c b/poll/unix/epoll.c
index 326dac7b1e90..fe006db013c0 100644
--- a/poll/unix/epoll.c
+++ b/poll/unix/epoll.c
@@ -104,14 +104,22 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
#ifndef HAVE_EPOLL_CREATE1
{
- int flags;
+ int fd_flags;
- if ((flags = fcntl(fd, F_GETFD)) == -1)
- return errno;
+ if ((fd_flags = fcntl(fd, F_GETFD)) == -1) {
+ rv = errno;
+ close(fd);
+ pollset->p = NULL;
+ return rv;
+ }
- flags |= FD_CLOEXEC;
- if (fcntl(fd, F_SETFD, flags) == -1)
- return errno;
+ fd_flags |= FD_CLOEXEC;
+ if (fcntl(fd, F_SETFD, fd_flags) == -1) {
+ rv = errno;
+ close(fd);
+ pollset->p = NULL;
+ return rv;
+ }
}
#endif
@@ -122,11 +130,13 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
((rv = apr_thread_mutex_create(&pollset->p->ring_lock,
APR_THREAD_MUTEX_DEFAULT,
p)) != APR_SUCCESS)) {
+ close(fd);
pollset->p = NULL;
return rv;
}
#else
if (flags & APR_POLLSET_THREADSAFE) {
+ close(fd);
pollset->p = NULL;
return APR_ENOTIMPL;
}
@@ -345,14 +355,23 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb,
#ifndef HAVE_EPOLL_CREATE1
{
- int flags;
-
- if ((flags = fcntl(fd, F_GETFD)) == -1)
- return errno;
+ int fd_flags;
+ apr_status_t rv;
+
+ if ((fd_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;
+ fd_flags |= FD_CLOEXEC;
+ if (fcntl(fd, F_SETFD, fd_flags) == -1) {
+ rv = errno;
+ close(fd);
+ pollcb->fd = -1;
+ return rv;
+ }
}
#endif