]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timer: Do not recalculate monotonic elapse time on clock change
authorFleuria <fleuria@posteo.co>
Thu, 3 Apr 2025 13:18:38 +0000 (20:18 +0700)
committerLennart Poettering <lennart@poettering.net>
Fri, 27 Jun 2025 12:45:02 +0000 (14:45 +0200)
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

index e283a97983fd267db4adcba24998be9365e758a1..a45e0c393fe634b8c1620525390a801ea3b05330 100644 (file)
@@ -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 &&