diff options
author | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2016-08-10 14:41:08 +0000 |
---|---|---|
committer | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2016-08-10 14:41:08 +0000 |
commit | b65f9ded49654f77714ee1c22937f9a9d3151d9f (patch) | |
tree | 963c29d5e7dc8f145a8b1401710dd9e898a41f0b | |
parent | 93163edc9637250569fe6c6fa9f7db6fb3aaa97c (diff) | |
download | libapr-b65f9ded49654f77714ee1c22937f9a9d3151d9f.tar.gz |
apr_pollset_poll(): don't return a positive (nay negative in case of error)
number of descriptors/events, before the returned descriptors are actually
initialized.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1755758 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poll/unix/epoll.c | 4 | ||||
-rw-r--r-- | poll/unix/kqueue.c | 3 | ||||
-rw-r--r-- | poll/unix/poll.c | 4 | ||||
-rw-r--r-- | poll/unix/port.c | 2 | ||||
-rw-r--r-- | poll/unix/select.c | 4 |
5 files changed, 9 insertions, 8 deletions
diff --git a/poll/unix/epoll.c b/poll/unix/epoll.c index 23686d5f5..af10145aa 100644 --- a/poll/unix/epoll.c +++ b/poll/unix/epoll.c @@ -258,14 +258,14 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, int ret; apr_status_t rv = APR_SUCCESS; + *num = 0; + if (timeout > 0) { timeout /= 1000; } ret = epoll_wait(pollset->p->epoll_fd, pollset->p->pollset, pollset->nalloc, timeout); - (*num) = ret; - if (ret < 0) { rv = apr_get_netos_error(); } diff --git a/poll/unix/kqueue.c b/poll/unix/kqueue.c index 355ccba99..d80434903 100644 --- a/poll/unix/kqueue.c +++ b/poll/unix/kqueue.c @@ -259,6 +259,8 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, apr_status_t rv = APR_SUCCESS; apr_pollfd_t fd; + *num = 0; + if (timeout < 0) { tvptr = NULL; } @@ -270,7 +272,6 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, ret = kevent(pollset->p->kqueue_fd, NULL, 0, pollset->p->ke_set, pollset->p->setsize, tvptr); - (*num) = ret; if (ret < 0) { rv = apr_get_netos_error(); } diff --git a/poll/unix/poll.c b/poll/unix/poll.c index 9f7ef2410..d8989aa43 100644 --- a/poll/unix/poll.c +++ b/poll/unix/poll.c @@ -241,10 +241,11 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, int ret; apr_status_t rv = APR_SUCCESS; + *num = 0; + #ifdef WIN32 /* WSAPoll() requires at least one socket. */ if (pollset->nelts == 0) { - *num = 0; if (timeout > 0) { apr_sleep(timeout); return APR_TIMEUP; @@ -261,7 +262,6 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, } ret = poll(pollset->p->pollset, pollset->nelts, timeout); #endif - *num = 0; if (ret < 0) { return apr_get_netos_error(); } diff --git a/poll/unix/port.c b/poll/unix/port.c index ee7700970..67432937f 100644 --- a/poll/unix/port.c +++ b/poll/unix/port.c @@ -360,6 +360,7 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, apr_status_t rv = APR_SUCCESS; apr_pollfd_t fp; + *num = 0; nget = 1; pollset_lock_rings(); @@ -403,7 +404,6 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, port_associate within apr_pollset_add() */ apr_atomic_dec32(&pollset->p->waiting); - (*num) = nget; if (nget) { pollset_lock_rings(); diff --git a/poll/unix/select.c b/poll/unix/select.c index b12f12ec7..214111a40 100644 --- a/poll/unix/select.c +++ b/poll/unix/select.c @@ -347,13 +347,14 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, fd_set readset, writeset, exceptset; apr_status_t rv = APR_SUCCESS; + *num = 0; + #ifdef WIN32 /* On Win32, select() must be presented with at least one socket to * poll on, or select() will return WSAEINVAL. So, we'll just * short-circuit and bail now. */ if (pollset->nelts == 0) { - (*num) = 0; if (timeout > 0) { apr_sleep(timeout); return APR_TIMEUP; @@ -385,7 +386,6 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset, rs = select(pollset->p->maxfd + 1, &readset, &writeset, &exceptset, tvptr); - (*num) = rs; if (rs < 0) { return apr_get_netos_error(); } |