X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Funit.c;h=001d7659c430d745e26881890bc9f40ab6b5fe1c;hp=bca4d97993c9acae1411e6aed0530aaa5c1d53b2;hb=f73d93a4d9403d44bf3661bf383ac1385e5b5eb6;hpb=fdf20a316035779bbec469e11d73c7544acbf30f diff --git a/src/unit.c b/src/unit.c index bca4d9799..001d7659c 100644 --- a/src/unit.c +++ b/src/unit.c @@ -1084,7 +1084,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) { * something is already activated. */ if (unexpected && u->meta.manager->n_deserializing <= 0) { - if (UNIT_IS_INACTIVE_OR_DEACTIVATING(os) && UNIT_IS_ACTIVE_OR_ACTIVATING(ns)) + if (UNIT_IS_INACTIVE_OR_FAILED(os) && UNIT_IS_ACTIVE_OR_ACTIVATING(ns)) retroactively_start_dependencies(u); else if (UNIT_IS_ACTIVE_OR_ACTIVATING(os) && UNIT_IS_INACTIVE_OR_DEACTIVATING(ns)) retroactively_stop_dependencies(u); @@ -2125,6 +2125,20 @@ Unit *unit_following(Unit *u) { return NULL; } +bool unit_pending_inactive(Unit *u) { + assert(u); + + /* Returns true if the unit is inactive or going down */ + + if (UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u))) + return true; + + if (u->meta.job && u->meta.job->type == JOB_STOP) + return true; + + return false; +} + static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = { [UNIT_STUB] = "stub", [UNIT_LOADED] = "loaded",