From 0b9b2d735c6f2255c2370ef3ede2be83b9a8942f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Fri, 13 Dec 2019 14:20:41 +0100 Subject: [PATCH] Backend: Improved fix for busy-wait on short call_outs (< 1ms) and poll. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The conversion from µs to ms now rounds up (instead of down), and the minimum wait of 2ms is removed. This makes it possible to (once again) schedule call_outs to be called immediately (instead of in 2ms). Thanks to Tomasz Jamroszczak <tjamroszczak@opera.com> for the report, and to Tobi for the analysis. Fixes [LysLysKOM 23729673]. --- src/backend.cmod | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend.cmod b/src/backend.cmod index 126f3d0f74..393b7106c4 100644 --- a/src/backend.cmod +++ b/src/backend.cmod @@ -3423,8 +3423,8 @@ static void noteEvents(CFFileDescriptorRef fdref, CFOptionFlags UNUSED(callBackT else if(next_timeout->tv_sec > (INT_MAX/1002)) /* about 24 days.*/ poll_timeout = INT_MAX/1002; else - poll_timeout = MAX((next_timeout->tv_sec*1000) + - next_timeout->tv_usec/1000,2); + poll_timeout = (next_timeout->tv_sec*1000) + + (next_timeout->tv_usec + 999)/1000; #elif defined(TIMEOUT_IS_TIMEVAL) poll_timeout = *next_timeout; #elif defined(TIMEOUT_IS_TIMESPEC) @@ -4112,7 +4112,7 @@ PIKECLASS PollBackend poll_timeout = INT_MAX; else poll_timeout = (next_timeout->tv_sec*1000) + - next_timeout->tv_usec/1000; + (next_timeout->tv_usec + 999)/1000; pb_copy_selectors(& pb->active_set, &pb->set); -- GitLab