Michal Schmidt e43452
From 43664cdd8565ae24b27c3f91be1de64ae9021608 Mon Sep 17 00:00:00 2001
Michal Schmidt e43452
From: Michal Schmidt <mschmidt@redhat.com>
Michal Schmidt e43452
Date: Fri, 9 Dec 2011 15:24:04 +0100
Michal Schmidt f1996e
Subject: [PATCH] unit: fix false positive in check for unneeded unit
Michal Schmidt e43452
Michal Schmidt e43452
A freshly started unit A was immediately considered unneeded just because
Michal Schmidt e43452
unit B, which Requires A, was starting later in the transaction.
Michal Schmidt e43452
Fix it by looking not only at the state of B, but also at its pending job.
Michal Schmidt e43452
Michal Schmidt e43452
Also fix a copied&pasted comment.
Michal Schmidt e43452
(cherry picked from commit f60c2665f9ba1dd4a6b4a36b2e8195482ada9957)
Michal Schmidt e43452
---
Michal Schmidt e43452
 src/unit.c |   10 +++++-----
Michal Schmidt e43452
 1 files changed, 5 insertions(+), 5 deletions(-)
Michal Schmidt e43452
Michal Schmidt e43452
diff --git a/src/unit.c b/src/unit.c
Michal Schmidt e43452
index 018e986..56137d7 100644
Michal Schmidt e43452
--- a/src/unit.c
Michal Schmidt e43452
+++ b/src/unit.c
Michal Schmidt e43452
@@ -1032,19 +1032,19 @@ static void unit_check_unneeded(Unit *u) {
Michal Schmidt e43452
                 return;
Michal Schmidt e43452
 
Michal Schmidt e43452
         SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
Michal Schmidt e43452
-                if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
Michal Schmidt e43452
+                if (unit_pending_active(other))
Michal Schmidt e43452
                         return;
Michal Schmidt e43452
 
Michal Schmidt e43452
         SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
Michal Schmidt e43452
-                if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
Michal Schmidt e43452
+                if (unit_pending_active(other))
Michal Schmidt e43452
                         return;
Michal Schmidt e43452
 
Michal Schmidt e43452
         SET_FOREACH(other, u->meta.dependencies[UNIT_WANTED_BY], i)
Michal Schmidt e43452
-                if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
Michal Schmidt e43452
+                if (unit_pending_active(other))
Michal Schmidt e43452
                         return;
Michal Schmidt e43452
 
Michal Schmidt e43452
         SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i)
Michal Schmidt e43452
-                if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
Michal Schmidt e43452
+                if (unit_pending_active(other))
Michal Schmidt e43452
                         return;
Michal Schmidt e43452
 
Michal Schmidt e43452
         log_info("Service %s is not needed anymore. Stopping.", u->meta.id);
Michal Schmidt e43452
@@ -2518,7 +2518,7 @@ bool unit_pending_inactive(Unit *u) {
Michal Schmidt e43452
 bool unit_pending_active(Unit *u) {
Michal Schmidt e43452
         assert(u);
Michal Schmidt e43452
 
Michal Schmidt e43452
-        /* Returns true if the unit is inactive or going down */
Michal Schmidt e43452
+        /* Returns true if the unit is active or going up */
Michal Schmidt e43452
 
Michal Schmidt e43452
         if (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)))
Michal Schmidt e43452
                 return true;