summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-07-15 20:32:47 +0200
committerMike Yuan <me@yhndnzj.com>2024-07-17 18:14:31 +0200
commit27344f9acf7b23225020cc4a2d63d5e10d35308f (patch)
treeab87ed12b7d60343ff0f2ef3c4f5af57565529ff
parentcore/unit: rename a few more vars for unit_next_freezer_state() (diff)
downloadsystemd-27344f9acf7b23225020cc4a2d63d5e10d35308f.tar.xz
systemd-27344f9acf7b23225020cc4a2d63d5e10d35308f.zip
core/cgroup: replace hardcoded state set with freezer_state_finish()
This makes code simpler and more readable.
-rw-r--r--src/core/cgroup.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index e370a04b8f..8abfd31c7b 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -5131,10 +5131,11 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
if (current == objective)
next = freezer_state_finish(next);
- else if (IN_SET(next, FREEZER_FROZEN, FREEZER_FROZEN_BY_PARENT, FREEZER_RUNNING)) {
- /* We're transitioning into a finished state, which implies that the cgroup's
- * current state already matches the objective and thus we'd return 0. But, reality
- * shows otherwise. This indicates that our freezer_state tracking has diverged
+ else if (next == freezer_state_finish(next)) {
+ /* We're directly transitioning into a finished state, which in theory means that
+ * the cgroup's current state already matches the objective and thus we'd return 0.
+ * But, reality shows otherwise (such case would have been handled by current == objective
+ * branch above). This indicates that our freezer_state tracking has diverged
* from the real state of the cgroup, which can happen if someone meddles with the
* cgroup from underneath us. This really shouldn't happen during normal operation,
* though. So, let's warn about it and fix up the state to be valid */