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