summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2016-08-10 15:29:32 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2016-08-10 15:29:32 +0000
commit5bfb58745b23be8152e00c98fd5d44df16001d32 (patch)
treebe2bcbb5026c47b849e2a4c82caa845023d06ca4
parent0a4f29bb66e26f52abccf82c2e869725fd121a58 (diff)
downloadlibapr-5bfb58745b23be8152e00c98fd5d44df16001d32.tar.gz
Merge r1671389, r1671513, r1755758 from trunk:
poll() implementation of apr_pollset_poll(): Return APR_EINTR as appropriate. (APR_SUCCESS was returned instead in that scenario.) [Note backport: the below is a partial revert only] Revert r1671389; apr_pollset_poll() should return APR_SUCCESS and the real event if a real event occurs AND apr_pollset_wakeup() is called before apr_pollset_poll() is called and/or awakened. 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. Submitted by: trawick, ylavic git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1755769 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poll/unix/epoll.c4
-rw-r--r--poll/unix/kqueue.c3
-rw-r--r--poll/unix/poll.c7
-rw-r--r--poll/unix/port.c2
-rw-r--r--poll/unix/select.c4
5 files changed, 11 insertions, 9 deletions
diff --git a/poll/unix/epoll.c b/poll/unix/epoll.c
index 535f99bb1..3a4aef502 100644
--- a/poll/unix/epoll.c
+++ b/poll/unix/epoll.c
@@ -259,14 +259,14 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
apr_status_t rv = APR_SUCCESS;
apr_pollfd_t *fdptr;
+ *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 efc589869..ad0d11484 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 d7a436fd9..4f572d26f 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) = ret;
if (ret < 0) {
return apr_get_netos_error();
}
@@ -290,8 +290,9 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
}
}
}
- if (((*num) = j) > 0)
+ if ((*num = j)) { /* any event besides wakeup pipe? */
rv = APR_SUCCESS;
+ }
}
if (descriptors && (*num))
*descriptors = pollset->p->result_set;
diff --git a/poll/unix/port.c b/poll/unix/port.c
index 5002dfdbe..5a78d5597 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 61a064f46..9bf8ce9e5 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();
}