mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
core: make use of unit_active_or_pending() where we can
Let's make use of unit_active_or_pending() where we can. Note that this change changes beaviour in one specific case: when shutdown.target is active we'll now also return that the system is in "stopping" state, not only when we try to get into it. That makes sense as shutdown.target is ordered before the actually shutdown units such as "systemd-poweroff.service", and if the state is queried between reaching those we should also report "stopping".
This commit is contained in:
parent
49d5666cc5
commit
e68537f0ba
@ -3542,20 +3542,18 @@ ManagerState manager_state(Manager *m) {
|
||||
return MANAGER_STARTING;
|
||||
}
|
||||
|
||||
/* Is the special shutdown target queued? If so, we are in shutdown state */
|
||||
/* Is the special shutdown target active or queued? If so, we are in shutdown state */
|
||||
u = manager_get_unit(m, SPECIAL_SHUTDOWN_TARGET);
|
||||
if (u && u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_RELOAD_OR_START))
|
||||
if (unit_active_or_pending(u))
|
||||
return MANAGER_STOPPING;
|
||||
|
||||
/* Are the rescue or emergency targets active or queued? If so we are in maintenance state */
|
||||
u = manager_get_unit(m, SPECIAL_RESCUE_TARGET);
|
||||
if (u && (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)) ||
|
||||
(u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_RELOAD_OR_START))))
|
||||
if (unit_active_or_pending(u))
|
||||
return MANAGER_MAINTENANCE;
|
||||
|
||||
u = manager_get_unit(m, SPECIAL_EMERGENCY_TARGET);
|
||||
if (u && (UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u)) ||
|
||||
(u->job && IN_SET(u->job->type, JOB_START, JOB_RESTART, JOB_RELOAD_OR_START))))
|
||||
if (unit_active_or_pending(u))
|
||||
return MANAGER_MAINTENANCE;
|
||||
|
||||
/* Are there any failed units? If so, we are in degraded mode */
|
||||
|
Loading…
x
Reference in New Issue
Block a user