From c831c9084afffdf10fa5dda865a6df5d643d83dd Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 5 Jul 2024 13:48:14 +0200 Subject: Round up expiration time for timers Otherwise we won't properly guarantee that we'll wait *at least* as long as the specified time. --- common/rfb/Timer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/rfb/Timer.cxx b/common/rfb/Timer.cxx index 5216c7e3..4654d50c 100644 --- a/common/rfb/Timer.cxx +++ b/common/rfb/Timer.cxx @@ -54,7 +54,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; -- cgit v1.2.3