summaryrefslogtreecommitdiffstats
path: root/poll/unix
diff options
context:
space:
mode:
Diffstat (limited to 'poll/unix')
-rw-r--r--poll/unix/epoll.c4
-rw-r--r--poll/unix/poll.c21
-rw-r--r--poll/unix/z_asio.c3
3 files changed, 16 insertions, 12 deletions
diff --git a/poll/unix/epoll.c b/poll/unix/epoll.c
index 4ab03f6..ad3cc0b 100644
--- a/poll/unix/epoll.c
+++ b/poll/unix/epoll.c
@@ -261,7 +261,7 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
*num = 0;
if (timeout > 0) {
- timeout /= 1000;
+ timeout = (timeout + 999) / 1000;
}
ret = epoll_wait(pollset->p->epoll_fd, pollset->p->pollset, pollset->nalloc,
@@ -442,7 +442,7 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
apr_status_t rv = APR_SUCCESS;
if (timeout > 0) {
- timeout /= 1000;
+ timeout = (timeout + 999) / 1000;
}
ret = epoll_wait(pollcb->fd, pollcb->pollset.epoll, pollcb->nalloc,
diff --git a/poll/unix/poll.c b/poll/unix/poll.c
index 5b878f1..28090c4 100644
--- a/poll/unix/poll.c
+++ b/poll/unix/poll.c
@@ -114,7 +114,8 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num,
num_to_poll = i;
if (timeout > 0) {
- timeout /= 1000; /* convert microseconds to milliseconds */
+ /* convert microseconds to milliseconds (round up) */
+ timeout = (timeout + 999) / 1000;
}
i = poll(pollset, num_to_poll, timeout);
@@ -252,14 +253,15 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
}
return APR_SUCCESS;
}
+#endif
+
if (timeout > 0) {
- timeout /= 1000;
+ timeout = (timeout + 999) / 1000;
}
+
+#ifdef WIN32
ret = WSAPoll(pollset->p->pollset, pollset->nelts, (int)timeout);
#else
- if (timeout > 0) {
- timeout /= 1000;
- }
ret = poll(pollset->p->pollset, pollset->nelts, timeout);
#endif
if (ret < 0) {
@@ -407,14 +409,15 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
}
return APR_SUCCESS;
}
+#endif
+
if (timeout > 0) {
- timeout /= 1000;
+ timeout = (timeout + 999) / 1000;
}
+
+#ifdef WIN32
ret = WSAPoll(pollcb->pollset.ps, pollcb->nelts, (int)timeout);
#else
- if (timeout > 0) {
- timeout /= 1000;
- }
ret = poll(pollcb->pollset.ps, pollcb->nelts, timeout);
#endif
if (ret < 0) {
diff --git a/poll/unix/z_asio.c b/poll/unix/z_asio.c
index 48b531c..e7d9d9d 100644
--- a/poll/unix/z_asio.c
+++ b/poll/unix/z_asio.c
@@ -554,7 +554,7 @@ static posix_poll(apr_pollset_t *pollset,
DBG(4, "entered\n");
if (timeout > 0) {
- timeout /= 1000;
+ timeout = (timeout + 999) / 1000;
}
rv = poll(priv->pollset, pollset->nelts, timeout);
(*num) = rv;
@@ -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 "