From aa6a6442c22e4e9a022ff87594fedaa80f52a30c Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Sat, 16 Mar 2019 20:47:59 +0100 Subject: [PATCH] Fix conversion of {sec,nsec} to msec in timedwait on Windows Internally time stamps and durations are all in nanoseconds, but the platform abstraction uses {sec,nsec} (essentially a struct timespec) and Windows uses milliseconds. The conversion to milliseconds with upwards rounding was broken, adding ~1s to each timeout. In most of the handful of uses the effect is minor in practice, but it does matter a lot in the scheduling of Heartbeat and AckNack messages, e.g., by causing a simple throughput test to exhibit periodic drops in throughput. Signed-off-by: Erik Boasson --- src/os/src/windows/os_platform_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/src/windows/os_platform_sync.c b/src/os/src/windows/os_platform_sync.c index 5084b13..1c36511 100644 --- a/src/os/src/windows/os_platform_sync.c +++ b/src/os/src/windows/os_platform_sync.c @@ -97,7 +97,7 @@ os_result os_condTimedWait(os_cond *cond, os_mutex *mutex, const os_time *time) assert(cond != NULL); assert(mutex != NULL); - timems = time->tv_sec * 1000 + (time->tv_nsec + 999999999) / 1000000; + timems = time->tv_sec * 1000 + (time->tv_nsec + 999999) / 1000000; if (SleepConditionVariableSRW(&cond->cond, &mutex->lock, timems, 0)) { return os_resultSuccess; } else if (GetLastError() != ERROR_TIMEOUT) {