X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ftimer.c;h=1c7010d120829ddada9accf9c5bb217228e8ec42;hp=96c6e8e8ed3affd0bbb554de7c97938baf4966b3;hb=398ef8ba0266cca453d90a90b3a2aa1caa44189f;hpb=6124958c7bda3fed9b079e8217781480797703f5 diff --git a/src/timer.c b/src/timer.c index 96c6e8e8e..1c7010d12 100644 --- a/src/timer.c +++ b/src/timer.c @@ -25,13 +25,15 @@ #include "unit-name.h" #include "timer.h" #include "dbus-timer.h" +#include "special.h" +#include "bus-errors.h" static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = { [TIMER_DEAD] = UNIT_INACTIVE, [TIMER_WAITING] = UNIT_ACTIVE, [TIMER_RUNNING] = UNIT_ACTIVE, [TIMER_ELAPSED] = UNIT_ACTIVE, - [TIMER_MAINTENANCE] = UNIT_INACTIVE_MAINTENANCE + [TIMER_MAINTENANCE] = UNIT_MAINTENANCE }; static void timer_init(Unit *u) { @@ -89,6 +91,11 @@ static int timer_load(Unit *u) { if ((r = unit_add_dependency(u, UNIT_BEFORE, t->unit, true)) < 0) return r; + + /* Timers shouldn't stay around on shutdown */ + if (t->meta.default_dependencies) + if ((r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0) + return r; } return timer_verify(t); @@ -255,18 +262,23 @@ fail: } static void timer_enter_running(Timer *t) { + DBusError error; int r; + assert(t); + dbus_error_init(&error); - if ((r = manager_add_job(t->meta.manager, JOB_START, t->unit, JOB_REPLACE, true, NULL)) < 0) + if ((r = manager_add_job(t->meta.manager, JOB_START, t->unit, JOB_REPLACE, true, &error, NULL)) < 0) goto fail; timer_set_state(t, TIMER_RUNNING); return; fail: - log_warning("%s failed to queue unit startup job: %s", t->meta.id, strerror(-r)); + log_warning("%s failed to queue unit startup job: %s", t->meta.id, bus_error(&error, r)); timer_enter_dead(t, false); + + dbus_error_free(&error); } static int timer_start(Unit *u) { @@ -434,11 +446,11 @@ static const char* const timer_state_table[_TIMER_STATE_MAX] = { DEFINE_STRING_TABLE_LOOKUP(timer_state, TimerState); static const char* const timer_base_table[_TIMER_BASE_MAX] = { - [TIMER_ACTIVE] = "OnActive", - [TIMER_BOOT] = "OnBoot", - [TIMER_STARTUP] = "OnStartup", - [TIMER_UNIT_ACTIVE] = "OnUnitActive", - [TIMER_UNIT_INACTIVE] = "OnUnitInactive" + [TIMER_ACTIVE] = "OnActiveSec", + [TIMER_BOOT] = "OnBootSec", + [TIMER_STARTUP] = "OnStartupSec", + [TIMER_UNIT_ACTIVE] = "OnUnitActiveSec", + [TIMER_UNIT_INACTIVE] = "OnUnitInactiveSec" }; DEFINE_STRING_TABLE_LOOKUP(timer_base, TimerBase);