summaryrefslogtreecommitdiffstats
path: root/contrib/apr/poll/unix/epoll.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/apr/poll/unix/epoll.c')
-rw-r--r--contrib/apr/poll/unix/epoll.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/contrib/apr/poll/unix/epoll.c b/contrib/apr/poll/unix/epoll.c
index 326dac7..fe006db 100644
--- a/contrib/apr/poll/unix/epoll.c
+++ b/contrib/apr/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
OpenPOWER on IntegriCloud