From bed9d2587c852c6dad5b2959a6313c8590e5d6a6 Mon Sep 17 00:00:00 2001 From: Fleuria Date: Thu, 3 Apr 2025 20:18:38 +0700 Subject: [PATCH] timer: Do not recalculate monotonic elapse time on clock change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only clock change that affects monotonic timers is suspend causing CLOCK_MONOTONIC to fall behind CLOCK_BOOTTIME. However, monotonic timers that use CLOCK_BOOTTIME are not intended to have their elapse time changed after a suspend. Hence condition the calculation of monotonic timers’ elapse times on the cause not being a clock change. Fixes #29245 --- src/core/timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/timer.c b/src/core/timer.c index e283a97983..a45e0c393f 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -486,7 +486,8 @@ static void timer_enter_waiting(Timer *t, bool time_change) { assert_not_reached(); } - v->next_elapse = usec_add(usec_shift_clock(base, CLOCK_MONOTONIC, TIMER_MONOTONIC_CLOCK(t)), v->value); + if (!time_change) + v->next_elapse = usec_add(usec_shift_clock(base, CLOCK_MONOTONIC, TIMER_MONOTONIC_CLOCK(t)), v->value); if (dual_timestamp_is_set(&t->last_trigger) && !time_change &&