core: subscribe to /etc/localtime timezone changes and update timer elapsation accordingly

Fixes: #8233

This is our first real-life usecase for the new sd_event_add_inotify()
calls we just added.
This commit is contained in:
Lennart Poettering
2018-06-06 10:53:56 +02:00
parent 7feedd18fa
commit bbf5fd8e41
4 changed files with 126 additions and 0 deletions
+13
View File
@@ -819,6 +819,18 @@ static void timer_time_change(Unit *u) {
timer_enter_waiting(t, false);
}
static void timer_timezone_change(Unit *u) {
Timer *t = TIMER(u);
assert(u);
if (t->state != TIMER_WAITING)
return;
log_unit_debug(u, "Timezone change, recalculating next elapse.");
timer_enter_waiting(t, false);
}
static const char* const timer_base_table[_TIMER_BASE_MAX] = {
[TIMER_ACTIVE] = "OnActiveSec",
[TIMER_BOOT] = "OnBootSec",
@@ -868,6 +880,7 @@ const UnitVTable timer_vtable = {
.reset_failed = timer_reset_failed,
.time_change = timer_time_change,
.timezone_change = timer_timezone_change,
.bus_vtable = bus_timer_vtable,
.bus_set_property = bus_timer_set_property,