summaryrefslogtreecommitdiff
path: root/src/core/timer.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-11-25 00:32:40 +0100
committerLennart Poettering <lennart@poettering.net>2012-11-25 00:33:59 +0100
commit8742514c1a1a5bc0f423da9101deb66115e187ff (patch)
tree87886e4f9625e7ed2c50889b817961a981cc8887 /src/core/timer.c
parentf0d7b0fcff57ff766b9882d4b11d79c9e478c3bc (diff)
timer: recalculate next elapse for calendar timer units when the system clock is changed
Diffstat (limited to 'src/core/timer.c')
-rw-r--r--src/core/timer.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/timer.c b/src/core/timer.c
index 54c0d0b330..bd27970449 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -527,6 +527,18 @@ static void timer_reset_failed(Unit *u) {
t->result = TIMER_SUCCESS;
}
+static void timer_time_change(Unit *u) {
+ Timer *t = TIMER(u);
+
+ assert(u);
+
+ if (t->state != TIMER_WAITING)
+ return;
+
+ log_info("%s: time change, recalculating next elapse.", u->id);
+ timer_enter_waiting(t, false);
+}
+
static const char* const timer_state_table[_TIMER_STATE_MAX] = {
[TIMER_DEAD] = "dead",
[TIMER_WAITING] = "waiting",
@@ -582,6 +594,7 @@ const UnitVTable timer_vtable = {
.timer_event = timer_timer_event,
.reset_failed = timer_reset_failed,
+ .time_change = timer_time_change,
.bus_interface = "org.freedesktop.systemd1.Timer",
.bus_message_handler = bus_timer_message_handler,