X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Ftimer.c;h=8061f79e3aefddd31937eb49ce8ca7f874d7947c;hb=795607b22308f5b92073b012e43be1892fdd97c0;hp=31ef176e7e3d750c8867bc94d96d32063494262c;hpb=66870f90dec9b5bf4ad76f9757fafce703560a67;p=elogind.git diff --git a/src/core/timer.c b/src/core/timer.c index 31ef176e7..8061f79e3 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); @@ -323,7 +330,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { log_debug_unit(UNIT(t)->id, "%s: Monotonic timer elapses in %s the next time.", 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)