summaryrefslogtreecommitdiff
path: root/support/unix
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-06-24 16:28:09 +0000
committerYann Ylavic <ylavic@apache.org>2022-06-24 16:28:09 +0000
commit289e1190dc612308e7497eb1f76b4863b34908a6 (patch)
tree48b47ce4f4a1fafeb947ab6ef6c94ad6374c5a86 /support/unix
parent5007efd1b2a1a703a7059cbd5b0e1e819e6359c8 (diff)
downloadapr-289e1190dc612308e7497eb1f76b4863b34908a6.tar.gz
poll: Round up milliseconds timeouts.
When converting appr_interval_time_t (usecs) to system call's msecs, round up. apr_*poll() calls should wait *at least* the given timeout, not less. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902236 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support/unix')
-rw-r--r--support/unix/waitio.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/support/unix/waitio.c b/support/unix/waitio.c
index fa5edb65e..a3c6a8349 100644
--- a/support/unix/waitio.c
+++ b/support/unix/waitio.c
@@ -42,10 +42,13 @@ apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s,
struct pollfd pfd;
int rc, timeout;
- timeout = f ? f->timeout / 1000 : s->timeout / 1000;
+ timeout = f ? f->timeout : s->timeout;
pfd.fd = f ? f->filedes : s->socketdes;
pfd.events = for_read ? POLLIN : POLLOUT;
+ if (timeout > 0) {
+ timeout = (timeout + 999) / 1000;
+ }
do {
rc = poll(&pfd, 1, timeout);
} while (rc == -1 && errno == EINTR);