]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/cgroup: replace hardcoded state set with freezer_state_finish()
authorMike Yuan <me@yhndnzj.com>
Mon, 15 Jul 2024 18:32:47 +0000 (20:32 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Jul 2025 11:08:03 +0000 (13:08 +0200)
This makes code simpler and more readable.

(cherry picked from commit 27344f9acf7b23225020cc4a2d63d5e10d35308f)

src/core/cgroup.c

index 381874b2be4a18b872744e07409fb17569f4ea31..54bf353f0ae5b0fe76f14800a5f19523f548376c 100644 (file)
@@ -5148,10 +5148,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 */