chiark / gitweb /
cgroup: add missing equals for BlockIOWeight
[elogind.git] / src / core / timer.c
index b5d895f048ca99596eeeb50c5ac6d2f2119a7b24..9166c1e2fc65ac3b450f9587298f1a5eab6e48c1 100644 (file)
@@ -251,11 +251,6 @@ static void timer_enter_waiting(Timer *t, bool initial) {
                         if (r < 0)
                                 continue;
 
-                        if (!initial && v->next_elapse < ts.realtime) {
-                                v->disabled = true;
-                                continue;
-                        }
-
                         if (!found_realtime)
                                 t->next_elapse_realtime = v->next_elapse;
                         else
@@ -284,18 +279,26 @@ static void timer_enter_waiting(Timer *t, bool initial) {
 
                         case TIMER_UNIT_ACTIVE:
 
-                                if (UNIT_TRIGGER(UNIT(t))->inactive_exit_timestamp.monotonic <= 0)
+                                base = UNIT_TRIGGER(UNIT(t))->inactive_exit_timestamp.monotonic;
+
+                                if (base <= 0)
+                                        base = t->last_trigger_monotonic;
+
+                                if (base <= 0)
                                         continue;
 
-                                base = UNIT_TRIGGER(UNIT(t))->inactive_exit_timestamp.monotonic;
                                 break;
 
                         case TIMER_UNIT_INACTIVE:
 
-                                if (UNIT_TRIGGER(UNIT(t))->inactive_enter_timestamp.monotonic <= 0)
+                                base = UNIT_TRIGGER(UNIT(t))->inactive_enter_timestamp.monotonic;
+
+                                if (base <= 0)
+                                        base = t->last_trigger_monotonic;
+
+                                if (base <= 0)
                                         continue;
 
-                                base = UNIT_TRIGGER(UNIT(t))->inactive_enter_timestamp.monotonic;
                                 break;
 
                         default:
@@ -304,7 +307,10 @@ static void timer_enter_waiting(Timer *t, bool initial) {
 
                         v->next_elapse = base + v->value;
 
-                        if (!initial && v->next_elapse < ts.monotonic) {
+                        if (!initial &&
+                            v->next_elapse < ts.monotonic &&
+                            (v->base == TIMER_ACTIVE || v->base == TIMER_BOOT || v->base == TIMER_STARTUP)) {
+                                /* This is a one time trigger, disable it now */
                                 v->disabled = true;
                                 continue;
                         }
@@ -368,7 +374,7 @@ static void timer_enter_running(Timer *t) {
         dbus_error_init(&error);
 
         /* Don't start job if we are supposed to go down */
-        if (unit_pending_inactive(UNIT(t)))
+        if (unit_stop_pending(UNIT(t)))
                 return;
 
         r = manager_add_job(UNIT(t)->manager, JOB_START, UNIT_TRIGGER(UNIT(t)),
@@ -376,6 +382,8 @@ static void timer_enter_running(Timer *t) {
         if (r < 0)
                 goto fail;
 
+        t->last_trigger_monotonic = now(CLOCK_MONOTONIC);
+
         timer_set_state(t, TIMER_RUNNING);
         return;
 
@@ -456,13 +464,13 @@ static int timer_deserialize_item(Unit *u, const char *key, const char *value, F
         return 0;
 }
 
-static UnitActiveState timer_active_state(Unit *u) {
+_pure_ static UnitActiveState timer_active_state(Unit *u) {
         assert(u);
 
         return state_translation_table[TIMER(u)->state];
 }
 
-static const char *timer_sub_state_to_string(Unit *u) {
+_pure_ static const char *timer_sub_state_to_string(Unit *u) {
         assert(u);
 
         return timer_state_to_string(TIMER(u)->state);
@@ -488,8 +496,6 @@ static void timer_trigger_notify(Unit *u, Unit *other) {
         assert(u);
         assert(other);
 
-        log_error("NOTIFY!");
-
         if (other->load_state != UNIT_LOADED)
                 return;