summaryrefslogtreecommitdiff
path: root/poll/unix/poll.c
diff options
context:
space:
mode:
Diffstat (limited to 'poll/unix/poll.c')
-rw-r--r--poll/unix/poll.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/poll/unix/poll.c b/poll/unix/poll.c
index 8c890d983..97a636019 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);
@@ -235,6 +236,9 @@ 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) {
@@ -244,14 +248,8 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
}
return APR_SUCCESS;
}
- if (timeout > 0) {
- timeout /= 1000;
- }
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) {
@@ -394,6 +392,10 @@ 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) {
@@ -403,14 +405,8 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
}
return APR_SUCCESS;
}
- if (timeout > 0) {
- timeout /= 1000;
- }
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) {