X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Ftimer.c;h=16b49174d366cbcebd43cc6cc10c84d1a6ed9e7d;hb=d51539b182c0a8869e2063e82d04f8a5849bfbab;hp=31ef176e7e3d750c8867bc94d96d32063494262c;hpb=f274ece0f76b5709408821e317e87aef76123db6;p=elogind.git diff --git a/src/core/timer.c b/src/core/timer.c index 31ef176e7..16b49174d 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -48,8 +48,7 @@ static void timer_init(Unit *u) { watch_init(&t->realtime_watch); } -static void timer_done(Unit *u) { - Timer *t = TIMER(u); +void timer_free_values(Timer *t) { TimerValue *v; assert(t); @@ -62,6 +61,14 @@ static void timer_done(Unit *u) { free(v); } +} + +static void timer_done(Unit *u) { + Timer *t = TIMER(u); + + assert(t); + + timer_free_values(t); unit_unwatch_timer(u, &t->monotonic_watch); unit_unwatch_timer(u, &t->realtime_watch); @@ -89,11 +96,11 @@ static int timer_add_default_dependencies(Timer *t) { assert(t); - if (UNIT(t)->manager->running_as == SYSTEMD_SYSTEM) { - r = unit_add_dependency_by_name(UNIT(t), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true); - if (r < 0) - return r; + r = unit_add_dependency_by_name(UNIT(t), UNIT_BEFORE, SPECIAL_TIMERS_TARGET, NULL, true); + if (r < 0) + return r; + if (UNIT(t)->manager->running_as == SYSTEMD_SYSTEM) { r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true); if (r < 0) return r; @@ -321,9 +328,9 @@ static void timer_enter_waiting(Timer *t, bool initial) { if (found_monotonic) { char buf[FORMAT_TIMESPAN_MAX]; log_debug_unit(UNIT(t)->id, - "%s: Monotonic timer elapses in %s the next time.", + "%s: Monotonic timer elapses in %s.", UNIT(t)->id, - format_timespan(buf, sizeof(buf), t->next_elapse_monotonic - ts.monotonic)); + format_timespan(buf, sizeof(buf), t->next_elapse_monotonic > ts.monotonic ? t->next_elapse_monotonic - ts.monotonic : 0)); r = unit_watch_timer(UNIT(t), CLOCK_MONOTONIC, false, t->next_elapse_monotonic, &t->monotonic_watch); if (r < 0) @@ -334,7 +341,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { if (found_realtime) { char buf[FORMAT_TIMESTAMP_MAX]; log_debug_unit(UNIT(t)->id, - "%s: Realtime timer elapses at %s the next time.", + "%s: Realtime timer elapses at %s.", UNIT(t)->id, format_timestamp(buf, sizeof(buf), t->next_elapse_realtime)); @@ -548,8 +555,8 @@ static void timer_time_change(Unit *u) { if (t->state != TIMER_WAITING) return; - log_info_unit(u->id, - "%s: time change, recalculating next elapse.", u->id); + log_debug_unit(u->id, + "%s: time change, recalculating next elapse.", u->id); timer_enter_waiting(t, false); }