summaryrefslogtreecommitdiff
path: root/poll
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2016-08-10 14:41:08 +0000
committerYann Ylavic <ylavic@apache.org>2016-08-10 14:41:08 +0000
commit9443bc3d87ff5f913e9e52286505cd5d6cee1404 (patch)
tree963c29d5e7dc8f145a8b1401710dd9e898a41f0b /poll
parente95483afc69126459ec92c3ab6f2913046f21586 (diff)
downloadapr-9443bc3d87ff5f913e9e52286505cd5d6cee1404.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: https://svn.apache.org/repos/asf/apr/apr/trunk@1755758 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poll')
-rw-r--r--poll/unix/epoll.c4
-rw-r--r--poll/unix/kqueue.c3
-rw-r--r--poll/unix/poll.c4
-rw-r--r--poll/unix/port.c2
-rw-r--r--poll/unix/select.c4
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();
}