unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], true);
}
-static void timer_enter_waiting(Timer *t, bool initial);
+static void timer_enter_waiting(Timer *t, bool initial, bool time_change);
static int timer_coldplug(Unit *u) {
Timer *t = TIMER(u);
return 0;
if (t->deserialized_state == TIMER_WAITING)
- timer_enter_waiting(t, false);
+ timer_enter_waiting(t, false, false);
else
timer_set_state(t, t->deserialized_state);
log_unit_info(UNIT(t), "Adding %s random time.", format_timespan(s, sizeof(s), add, 0));
}
-static void timer_enter_waiting(Timer *t, bool initial) {
+static void timer_enter_waiting(Timer *t, bool initial, bool time_change) {
bool found_monotonic = false, found_realtime = false;
usec_t ts_realtime, ts_monotonic;
usec_t base = 0;
v->next_elapse = base + v->value;
- if (!initial && v->next_elapse < ts_monotonic && IN_SET(v->base, TIMER_ACTIVE, TIMER_BOOT, TIMER_STARTUP)) {
+ if (!initial && !time_change &&
+ v->next_elapse < ts_monotonic && IN_SET(v->base, TIMER_ACTIVE, TIMER_BOOT, TIMER_STARTUP)) {
/* This is a one time trigger, disable it now */
v->disabled = true;
continue;
}
t->result = TIMER_SUCCESS;
- timer_enter_waiting(t, true);
+ timer_enter_waiting(t, true, false);
return 1;
}
case TIMER_ELAPSED:
/* Recalculate sleep time */
- timer_enter_waiting(t, false);
+ timer_enter_waiting(t, false, false);
break;
case TIMER_RUNNING:
if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
log_unit_debug(UNIT(t), "Got notified about unit deactivation.");
- timer_enter_waiting(t, false);
+ timer_enter_waiting(t, false, false);
}
break;
return;
log_unit_debug(u, "Time change, recalculating next elapse.");
- timer_enter_waiting(t, false);
+ timer_enter_waiting(t, false, true);
}
static const char* const timer_base_table[_TIMER_BASE_MAX] = {