aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorKartik Naik <kartik@bugqore.com>2026-07-16 11:52:45 +0530
committerKartik Naik <kartik@bugqore.com>2026-07-16 11:52:45 +0530
commit9082d30d64e6765f930dc320addd1fda134a78c1 (patch)
treee69d60c00fe5922eefb9004ca5d37be22d19b68c /apps
parentb901cbc4d84bd4eb5dbb27dabc329ba03457274a (diff)
downloadportable-9082d30d64e6765f930dc320addd1fda134a78c1.tar.gz
portable-9082d30d64e6765f930dc320addd1fda134a78c1.tar.bz2
portable-9082d30d64e6765f930dc320addd1fda134a78c1.zip
poll_win: cap the final wait pass at the remaining time
The wait loop always sleeps in fixed 100ms slices, so a 250ms timeout runs three full passes and takes ~300ms. Clamp each pass to the time remaining so the total wait matches the requested timeout.
Diffstat (limited to 'apps')
-rw-r--r--apps/openssl/compat/poll_win.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/apps/openssl/compat/poll_win.c b/apps/openssl/compat/poll_win.c
index 0d15522..8e28349 100644
--- a/apps/openssl/compat/poll_win.c
+++ b/apps/openssl/compat/poll_win.c
@@ -264,6 +264,14 @@ poll(struct pollfd *pfds, nfds_t nfds, int timeout_ms)
264 264
265 do { 265 do {
266 TIMEVAL tv; 266 TIMEVAL tv;
267
268 /*
269 * Cap the wait at the time remaining so the final pass
270 * does not overshoot the requested timeout.
271 */
272 if (timeout_ms != -1 && timeout_ms - timespent_ms < looptime_ms)
273 looptime_ms = timeout_ms - timespent_ms;
274
267 tv.tv_sec = 0; 275 tv.tv_sec = 0;
268 tv.tv_usec = looptime_ms * 1000; 276 tv.tv_usec = looptime_ms * 1000;
269 int handle_signaled = 0; 277 int handle_signaled = 0;