Fix issue with system time set back (#24131)

Fixes #6036
This commit is contained in:
João Loureiro
2022-08-08 15:32:19 +02:00
committed by GitHub
parent 7b45d6b6f6
commit 5ded3917a1
2 changed files with 39 additions and 23 deletions
+11 -12
View File
@@ -394,19 +394,18 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
if (v->base == TIMER_CALENDAR) {
usec_t b, rebased;
/* If we know the last time this was
* triggered, schedule the job based relative
* to that. If we don't, just start from
* the activation time. */
if (t->last_trigger.realtime > 0)
/* Update last_trigger to 'now' in case the system time changes, so that
* next_elapse is not stuck with a future date. */
if (time_change)
b = ts.realtime;
/* If we know the last time this was triggered, schedule the job based relative
* to that. If we don't, just start from the activation time. */
else if (t->last_trigger.realtime > 0)
b = t->last_trigger.realtime;
else {
if (state_translation_table[t->state] == UNIT_ACTIVE)
b = UNIT(t)->inactive_exit_timestamp.realtime;
else
b = ts.realtime;
}
else if (state_translation_table[t->state] == UNIT_ACTIVE)
b = UNIT(t)->inactive_exit_timestamp.realtime;
else
b = ts.realtime;
r = calendar_spec_next_usec(v->calendar_spec, b, &v->next_elapse);
if (r < 0)