diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-03-12 20:55:13 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-03-12 20:55:13 +0100 |
commit | f755e3b74b94296a534033dd6ae04d9506434210 (patch) | |
tree | 90298b78955a4a8995ce4b51b9a0364cb05be503 /src/core/unit.c | |
parent | 0325941fff60888ff3486f271b0d513a75f9a324 (diff) |
core: introduce system state enum
The system state knows the states starting →
running/degraded/maintenance → stopping, where:
starting = system startup
running = normal operation
degraded = at least one unit is currently in failed state
maintenance = rescue/emergency mode is active or queued
stopping = system shutdown
Diffstat (limited to 'src/core/unit.c')
-rw-r--r-- | src/core/unit.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index aa723cb8c5..5c98843549 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -471,6 +471,8 @@ void unit_free(Unit *u) { free(u->cgroup_path); } + set_remove(u->manager->failed_units, u); + free(u->description); strv_free(u->documentation); free(u->fragment_path); @@ -1507,6 +1509,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su m = u->manager; + /* Update timestamps for state changes */ if (m->n_reloading <= 0) { dual_timestamp ts; @@ -1523,6 +1526,13 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su u->active_exit_timestamp = ts; } + /* Keep track of failed of units */ + if (ns == UNIT_FAILED && os != UNIT_FAILED) + set_put(u->manager->failed_units, u); + else if (os == UNIT_FAILED && ns != UNIT_FAILED) + set_remove(u->manager->failed_units, u); + + /* Make sure the cgroup is always removed when we become inactive */ if (UNIT_IS_INACTIVE_OR_FAILED(ns)) unit_destroy_cgroup(u); |