From 9082d30d64e6765f930dc320addd1fda134a78c1 Mon Sep 17 00:00:00 2001 From: Kartik Naik Date: Thu, 16 Jul 2026 11:52:45 +0530 Subject: 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. --- apps/openssl/compat/poll_win.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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) do { TIMEVAL tv; + + /* + * Cap the wait at the time remaining so the final pass + * does not overshoot the requested timeout. + */ + if (timeout_ms != -1 && timeout_ms - timespent_ms < looptime_ms) + looptime_ms = timeout_ms - timespent_ms; + tv.tv_sec = 0; tv.tv_usec = looptime_ms * 1000; int handle_signaled = 0; -- cgit v1.2.3-55-g6feb