X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Funit.c;h=601be60ed0595311910218a2b916f0ae2112bbf5;hp=f8a913e39a5dbb466bba6fc06ac0ecfffc85cee1;hb=bf6dcfa6a79a459239799a21bdcba115d696a006;hpb=546ac4f0078228ef0bdd764dc7566cacf684c562 diff --git a/src/core/unit.c b/src/core/unit.c index f8a913e39..601be60ed 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1357,6 +1357,21 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su if (UNIT_IS_INACTIVE_OR_FAILED(ns)) cgroup_bonding_trim_list(u->cgroup_bondings, true); + if (UNIT_IS_INACTIVE_OR_FAILED(os) != UNIT_IS_INACTIVE_OR_FAILED(ns)) { + ExecContext *ec = unit_get_exec_context(u); + if (ec && exec_context_may_touch_console(ec)) { + /* XXX The counter may get out of sync if the admin edits + * TTY-related unit file properties and issues a daemon-reload + * while the unit is active. No big deal though, because + * it influences only the printing of boot/shutdown + * status messages. */ + if (UNIT_IS_INACTIVE_OR_FAILED(ns)) + m->n_on_console--; + else + m->n_on_console++; + } + } + if (u->job) { unexpected = false; @@ -1502,7 +1517,8 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su /* Maybe we finished startup and are now ready for being * stopped because unneeded? */ - unit_check_unneeded(u); + if (u->manager->n_reloading <= 0) + unit_check_unneeded(u); unit_add_to_dbus_queue(u); unit_add_to_gc_queue(u);