From: Michal Schmidt Date: Fri, 9 Dec 2011 14:24:04 +0000 (+0100) Subject: unit: fix false positive in check for unneeded unit X-Git-Tag: v38~167 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=f60c2665f9ba1dd4a6b4a36b2e8195482ada9957 unit: fix false positive in check for unneeded unit A freshly started unit A was immediately considered unneeded just because unit B, which Requires A, was starting later in the transaction. Fix it by looking not only at the state of B, but also at its pending job. Also fix a copied&pasted comment. --- diff --git a/src/unit.c b/src/unit.c index 018e9861c..56137d7bd 100644 --- a/src/unit.c +++ b/src/unit.c @@ -1032,19 +1032,19 @@ static void unit_check_unneeded(Unit *u) { return; SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i) - if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other))) + if (unit_pending_active(other)) return; SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i) - if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other))) + if (unit_pending_active(other)) return; SET_FOREACH(other, u->meta.dependencies[UNIT_WANTED_BY], i) - if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other))) + if (unit_pending_active(other)) return; SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i) - if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other))) + if (unit_pending_active(other)) return; log_info("Service %s is not needed anymore. Stopping.", u->meta.id); @@ -2518,7 +2518,7 @@ bool unit_pending_inactive(Unit *u) { bool unit_pending_active(Unit *u) { assert(u); - /* Returns true if the unit is inactive or going down */ + /* Returns true if the unit is active or going up */ if (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u))) return true;