chiark / gitweb /
journal: move field index from file into journal object
[elogind.git] / src / timer.c
index 0dcaad509184132473996ffea2f8799e27adc943..e6f207fbb6e6b8daa507a59a08a064d24f60608b 100644 (file)
@@ -78,11 +78,15 @@ static int timer_add_default_dependencies(Timer *t) {
 
         assert(t);
 
-        if (t->meta.manager->running_as == MANAGER_SYSTEM)
+        if (t->meta.manager->running_as == MANAGER_SYSTEM) {
+                if ((r = unit_add_dependency_by_name(UNIT(t), UNIT_BEFORE, SPECIAL_BASIC_TARGET, NULL, true)) < 0)
+                        return r;
+
                 if ((r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, NULL, true)) < 0)
                         return r;
+        }
 
-        return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTED_BY, SPECIAL_SHUTDOWN_TARGET, NULL, true);
+        return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
 }
 
 static int timer_load(Unit *u) {
@@ -148,7 +152,7 @@ static void timer_set_state(Timer *t, TimerState state) {
                           timer_state_to_string(old_state),
                           timer_state_to_string(state));
 
-        unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state]);
+        unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], true);
 }
 
 static void timer_enter_waiting(Timer *t, bool initial);
@@ -161,9 +165,7 @@ static int timer_coldplug(Unit *u) {
 
         if (t->deserialized_state != t->state) {
 
-                if (t->deserialized_state == TIMER_WAITING ||
-                    t->deserialized_state == TIMER_RUNNING ||
-                    t->deserialized_state == TIMER_ELAPSED)
+                if (t->deserialized_state == TIMER_WAITING)
                         timer_enter_waiting(t, false);
                 else
                         timer_set_state(t, t->deserialized_state);
@@ -197,9 +199,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;
 
@@ -476,6 +478,10 @@ DEFINE_STRING_TABLE_LOOKUP(timer_base, TimerBase);
 
 const UnitVTable timer_vtable = {
         .suffix = ".timer",
+        .sections =
+                "Unit\0"
+                "Timer\0"
+                "Install\0",
 
         .init = timer_init,
         .done = timer_done,