From 7232feee5a6ad79cbe96a27278ffacba1b12c7fa Mon Sep 17 00:00:00 2001 From: Chris Lee <@klee93> Date: Wed, 14 Apr 2021 23:38:36 +0200 Subject: [PATCH] fix incorrect timeout microsecond computation --- src/util/timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/timer.c b/src/util/timer.c index 8c05798..981e567 100644 --- a/src/util/timer.c +++ b/src/util/timer.c @@ -131,7 +131,8 @@ struct timeval *get_duration_to_next_timer_expiration() next_timer->expiration_time_ms_, next_timer->period_ms_); result.tv_sec = duration / 1000; - result.tv_usec = 1000 * (duration - result.tv_sec); + duration -= result.tv_sec * 1000; + result.tv_usec = 1000 * duration; return &result; }