ff2b41
From 83c66e1d0c1bc6e7522719250e77fad40a147870 Mon Sep 17 00:00:00 2001
ff2b41
From: Lennart Poettering <lennart@poettering.net>
ff2b41
Date: Tue, 9 Oct 2018 15:56:27 +0200
ff2b41
Subject: [PATCH] core: tiny tweak for cgroup trimming during manager_free()
ff2b41
ff2b41
Instead of blacklisting when not to trim the cgroup tree, let's instead
ff2b41
whitelist when to do it, as an excercise of being careful when being
ff2b41
destructive.
ff2b41
ff2b41
This should not change behaviour with exception that during switch roots
ff2b41
we now won't attempt to trim the cgroup tree anymore. Which is more
ff2b41
correct behaviour after all we serialize/deserialize during the
ff2b41
transition and should be needlessly destructive.
ff2b41
ff2b41
(cherry picked from commit 86036b26a1da4d90ca274d37e77c56980ab689fd)
ff2b41
ff2b41
Resolves: #1630378
ff2b41
---
ff2b41
 src/core/manager.c | 5 ++---
ff2b41
 1 file changed, 2 insertions(+), 3 deletions(-)
ff2b41
ff2b41
diff --git a/src/core/manager.c b/src/core/manager.c
ff2b41
index fdbb3c0fd9..afa4d2b8fa 100644
ff2b41
--- a/src/core/manager.c
ff2b41
+++ b/src/core/manager.c
ff2b41
@@ -998,9 +998,8 @@ Manager* manager_free(Manager *m) {
ff2b41
                 if (unit_vtable[c]->shutdown)
ff2b41
                         unit_vtable[c]->shutdown(m);
ff2b41
 
ff2b41
-        /* If we reexecute ourselves, we keep the root cgroup
ff2b41
-         * around */
ff2b41
-        manager_shutdown_cgroup(m, m->exit_code != MANAGER_REEXECUTE);
ff2b41
+        /* Keep the cgroup hierarchy in place except when we know we are going down for good */
ff2b41
+        manager_shutdown_cgroup(m, IN_SET(m->exit_code, MANAGER_EXIT, MANAGER_REBOOT, MANAGER_POWEROFF, MANAGER_HALT, MANAGER_KEXEC));
ff2b41
 
ff2b41
         manager_undo_generators(m);
ff2b41