Skip to content

Commit c8bf661

Browse files
DaanDeMeyerbluca
authored andcommitted
core/timer: Always use inactive_exit_timestamp if it is set
If we're doing a daemon-reload, we'll be going from TIMER_DEAD => TIMER_WAITING, so we won't use inactive_exit_timestamp because TIMER_DEAD != UNIT_ACTIVE, even though inactive_exit_timestamp is serialized/deserialized and will be valid after the daemon-reload. This issue can lead to timers never firing as we'll always calculate the next elapse based on the current realtime on daemon-reload, so if daemon-reload happens often enough, the elapse interval will be moved into the future every time, which means the timer will never trigger. To fix the issue, let's always use inactive_exit_timestamp if it is set, and only fall back to the current realtime if it is not set. (cherry picked from commit 6546045) (cherry picked from commit aa48ecb) (cherry picked from commit 48445d2)
1 parent 0a57d0d commit c8bf661

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/core/timer.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,10 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
401401

402402
if (t->last_trigger.realtime > 0)
403403
b = t->last_trigger.realtime;
404-
else {
405-
if (state_translation_table[t->state] == UNIT_ACTIVE)
406-
b = UNIT(t)->inactive_exit_timestamp.realtime;
407-
else
408-
b = ts.realtime;
409-
}
404+
else if (dual_timestamp_is_set(&UNIT(t)->inactive_exit_timestamp))
405+
b = UNIT(t)->inactive_exit_timestamp.realtime;
406+
else
407+
b = ts.realtime;
410408

411409
r = calendar_spec_next_usec(v->calendar_spec, b, &v->next_elapse);
412410
if (r < 0)

0 commit comments

Comments
 (0)