summaryrefslogtreecommitdiff
path: root/poll
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-06-26 12:21:33 +0000
committerYann Ylavic <ylavic@apache.org>2022-06-26 12:21:33 +0000
commite78d576c68eb2ffd517a9508ae2db4aa02f78a0f (patch)
tree0e89c834a27783426663f8983ec033b95d2dc4fd /poll
parent51c205578e2a10d1f28417179ac3ec2a3994ecfb (diff)
downloadapr-e78d576c68eb2ffd517a9508ae2db4aa02f78a0f.tar.gz
poll: Follow up to r1902236: Fix poll() sleeps cases.
Don't convert timeout to milliseconds before potentially callig apr_sleep(). Tests for "poll() didn't sleep" now use the real timeout as lower limit. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902258 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poll')
-rw-r--r--poll/unix/poll.c21
-rw-r--r--poll/unix/z_asio.c1
2 files changed, 15 insertions, 7 deletions
diff --git a/poll/unix/poll.c b/poll/unix/poll.c
index 97a636019..c33157296 100644
--- a/poll/unix/poll.c
+++ b/poll/unix/poll.c
@@ -236,9 +236,6 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
*num = 0;
- if (timeout > 0) {
- timeout = (timeout + 999) / 1000;
- }
#ifdef WIN32
/* WSAPoll() requires at least one socket. */
if (pollset->nelts == 0) {
@@ -248,6 +245,13 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
}
return APR_SUCCESS;
}
+#endif
+
+ if (timeout > 0) {
+ timeout = (timeout + 999) / 1000;
+ }
+
+#ifdef WIN32
ret = WSAPoll(pollset->p->pollset, pollset->nelts, (int)timeout);
#else
ret = poll(pollset->p->pollset, pollset->nelts, timeout);
@@ -392,10 +396,6 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
apr_status_t rv = APR_SUCCESS;
apr_uint32_t i;
- if (timeout > 0) {
- timeout = (timeout + 999) / 1000;
- }
-
#ifdef WIN32
/* WSAPoll() requires at least one socket. */
if (pollcb->nelts == 0) {
@@ -405,6 +405,13 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
}
return APR_SUCCESS;
}
+#endif
+
+ if (timeout > 0) {
+ timeout = (timeout + 999) / 1000;
+ }
+
+#ifdef WIN32
ret = WSAPoll(pollcb->pollset.ps, pollcb->nelts, (int)timeout);
#else
ret = poll(pollcb->pollset.ps, pollcb->nelts, timeout);
diff --git a/poll/unix/z_asio.c b/poll/unix/z_asio.c
index 8652f502d..e7d9d9da3 100644
--- a/poll/unix/z_asio.c
+++ b/poll/unix/z_asio.c
@@ -698,6 +698,7 @@ static apr_status_t asio_pollset_poll(apr_pollset_t *pollset,
tv.tv_nsec = apr_time_usec(timeout) * 1000;
} else {
tv.tv_sec = INT_MAX; /* block until something is ready */
+ tv.tv_nsec = 0;
}
DBG2(6, "nothing on the ready ring "