1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 16:59:03 +03:00

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.
This commit is contained in:
Michal Schmidt 2011-12-09 15:24:04 +01:00
parent 714d943f72
commit f60c2665f9

View File

@ -1032,19 +1032,19 @@ static void unit_check_unneeded(Unit *u) {
return; return;
SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i) 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; return;
SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i) 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; return;
SET_FOREACH(other, u->meta.dependencies[UNIT_WANTED_BY], i) 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; return;
SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i) 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; return;
log_info("Service %s is not needed anymore. Stopping.", u->meta.id); 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) { bool unit_pending_active(Unit *u) {
assert(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))) if (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)))
return true; return true;