From 7efa16f194b2815b46bb44d73721906c88ed9d07 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 5 Jul 2024 13:48:14 +0200 Subject: [PATCH] Round up expiration time for timers Otherwise we won't properly guarantee that we'll wait *at least* as long as the specified time. (cherry picked from commit c831c9084afffdf10fa5dda865a6df5d643d83dd) --- common/rfb/Timer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/rfb/Timer.cxx b/common/rfb/Timer.cxx index e9ae5227..e77a9ac3 100644 --- a/common/rfb/Timer.cxx +++ b/common/rfb/Timer.cxx @@ -52,7 +52,7 @@ inline static timeval addMillis(timeval inTime, int millis) { } inline static int diffTimeMillis(timeval later, timeval earlier) { - return ((later.tv_sec - earlier.tv_sec) * 1000) + ((later.tv_usec - earlier.tv_usec) / 1000); + return ((later.tv_sec - earlier.tv_sec) * 1000) + ((later.tv_usec - earlier.tv_usec + 999) / 1000); } std::list Timer::pending; -- 2.39.5