X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ftimer.c;h=b01944ccdbd34ae81322c74c66977280f91fb00a;hp=2c21b49197978e41418463d5b327ac182e43f403;hb=5c0532d1cc989d2f78d2cd4a18058daa58143705;hpb=69dd2852bb2c433b517d89792adb4461a4178aa1 diff --git a/src/timer.c b/src/timer.c index 2c21b4919..b01944ccd 100644 --- a/src/timer.c +++ b/src/timer.c @@ -1,4 +1,4 @@ -/*-*- Mode: C; c-basic-offset: 8 -*-*/ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ /*** This file is part of systemd. @@ -33,7 +33,7 @@ static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = { [TIMER_WAITING] = UNIT_ACTIVE, [TIMER_RUNNING] = UNIT_ACTIVE, [TIMER_ELAPSED] = UNIT_ACTIVE, - [TIMER_MAINTENANCE] = UNIT_MAINTENANCE + [TIMER_FAILED] = UNIT_FAILED }; static void timer_init(Unit *u) { @@ -114,15 +114,10 @@ static int timer_load(Unit *u) { static void timer_dump(Unit *u, FILE *f, const char *prefix) { Timer *t = TIMER(u); - const char *prefix2; - char *p2; TimerValue *v; char timespan1[FORMAT_TIMESPAN_MAX]; - p2 = strappend(prefix, "\t"); - prefix2 = p2 ? p2 : prefix; - fprintf(f, "%sTimer State: %s\n" "%sUnit: %s\n", @@ -135,8 +130,6 @@ static void timer_dump(Unit *u, FILE *f, const char *prefix) { prefix, timer_base_to_string(v->base), strna(format_timespan(timespan1, sizeof(timespan1), v->value))); - - free(p2); } static void timer_set_state(Timer *t, TimerState state) { @@ -185,7 +178,7 @@ static void timer_enter_dead(Timer *t, bool success) { if (!success) t->failure = true; - timer_set_state(t, t->failure ? TIMER_MAINTENANCE : TIMER_DEAD); + timer_set_state(t, t->failure ? TIMER_FAILED : TIMER_DEAD); } static void timer_enter_waiting(Timer *t, bool initial) { @@ -204,9 +197,9 @@ static void timer_enter_waiting(Timer *t, bool initial) { switch (v->base) { case TIMER_ACTIVE: - if (state_translation_table[t->state] == UNIT_ACTIVE) { + if (state_translation_table[t->state] == UNIT_ACTIVE) base = t->meta.inactive_exit_timestamp.monotonic; - } else + else base = n; break; @@ -300,7 +293,7 @@ static int timer_start(Unit *u) { Timer *t = TIMER(u); assert(t); - assert(t->state == TIMER_DEAD || t->state == TIMER_MAINTENANCE); + assert(t->state == TIMER_DEAD || t->state == TIMER_FAILED); if (t->unit->meta.load_state != UNIT_LOADED) return -ENOENT; @@ -428,7 +421,7 @@ void timer_unit_notify(Unit *u, UnitActiveState new_state) { case TIMER_RUNNING: - if (UNIT_IS_INACTIVE_OR_MAINTENANCE(new_state)) { + if (UNIT_IS_INACTIVE_OR_FAILED(new_state)) { log_debug("%s got notified about unit deactivation.", t->meta.id); timer_enter_waiting(t, false); } @@ -436,8 +429,8 @@ void timer_unit_notify(Unit *u, UnitActiveState new_state) { break; case TIMER_DEAD: - case TIMER_MAINTENANCE: - ; + case TIMER_FAILED: + break; default: assert_not_reached("Unknown timer state"); @@ -450,12 +443,12 @@ fail: log_error("Failed find timer unit: %s", strerror(-r)); } -static void timer_reset_maintenance(Unit *u) { +static void timer_reset_failed(Unit *u) { Timer *t = TIMER(u); assert(t); - if (t->state == TIMER_MAINTENANCE) + if (t->state == TIMER_FAILED) timer_set_state(t, TIMER_DEAD); t->failure = false; @@ -466,7 +459,7 @@ static const char* const timer_state_table[_TIMER_STATE_MAX] = { [TIMER_WAITING] = "waiting", [TIMER_RUNNING] = "running", [TIMER_ELAPSED] = "elapsed", - [TIMER_MAINTENANCE] = "maintenance" + [TIMER_FAILED] = "failed" }; DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState); @@ -503,7 +496,9 @@ const UnitVTable timer_vtable = { .timer_event = timer_timer_event, - .reset_maintenance = timer_reset_maintenance, + .reset_failed = timer_reset_failed, - .bus_message_handler = bus_timer_message_handler + .bus_interface = "org.freedesktop.systemd1.Timer", + .bus_message_handler = bus_timer_message_handler, + .bus_invalidating_properties = bus_timer_invalidating_properties };