X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Funit.c;h=b4a4f8cd2e28e2eda6867bb97ae9d4ad101a86f8;hb=31afa0a44c2d7f93d837c840cdbd623982ac165f;hp=c0c3ce90a7af56d01307cde4b90a74d69ba653fb;hpb=67fb4482acb0ecccb8a30e7ca49e5de28ba49eaf;p=elogind.git diff --git a/src/core/unit.c b/src/core/unit.c index c0c3ce90a..b4a4f8cd2 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1206,19 +1206,19 @@ static void unit_check_unneeded(Unit *u) { return; SET_FOREACH(other, u->dependencies[UNIT_REQUIRED_BY], i) - if (unit_pending_active(other)) + if (unit_active_or_pending(other)) return; SET_FOREACH(other, u->dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i) - if (unit_pending_active(other)) + if (unit_active_or_pending(other)) return; SET_FOREACH(other, u->dependencies[UNIT_WANTED_BY], i) - if (unit_pending_active(other)) + if (unit_active_or_pending(other)) return; SET_FOREACH(other, u->dependencies[UNIT_BOUND_BY], i) - if (unit_pending_active(other)) + if (unit_active_or_pending(other)) return; log_info_unit(u->id, "Service %s is not needed anymore. Stopping.", u->id); @@ -2651,21 +2651,30 @@ Unit *unit_following(Unit *u) { return NULL; } -bool unit_pending_inactive(Unit *u) { +bool unit_stop_pending(Unit *u) { assert(u); - /* Returns true if the unit is inactive or going down */ + /* This call does check the current state of the unit. It's + * hence useful to be called from state change calls of the + * unit itself, where the state isn't updated yet. This is + * different from unit_inactive_or_pending() which checks both + * the current state and for a queued job. */ - if (UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u))) - return true; + return u->job && u->job->type == JOB_STOP; +} + +bool unit_inactive_or_pending(Unit *u) { + assert(u); + + /* Returns true if the unit is inactive or going down */ - if (u->job && u->job->type == JOB_STOP) + if (unit_stop_pending(u)) return true; return false; } -bool unit_pending_active(Unit *u) { +bool unit_active_or_pending(Unit *u) { assert(u); /* Returns true if the unit is active or going up */