]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: units that aren't loaded properly should not result in cgroup controllers...
authorLennart Poettering <lennart@poettering.net>
Wed, 21 Nov 2018 17:25:37 +0000 (18:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Nov 2018 11:24:37 +0000 (12:24 +0100)
This shouldn't make much difference in real life, but is a bit cleaner.

src/core/cgroup.c

index 1aab238866c3603fafaaff4dd2989ec2c3697f3c..bc6df17c0be757fdcd40217a1534096ceac81797 100644 (file)
@@ -1270,7 +1270,11 @@ static CGroupMask unit_get_bpf_mask(Unit *u) {
 CGroupMask unit_get_own_mask(Unit *u) {
         CGroupContext *c;
 
-        /* Returns the mask of controllers the unit needs for itself */
+        /* Returns the mask of controllers the unit needs for itself. If a unit is not properly loaded, return an empty
+         * mask, as we shouldn't reflect it in the cgroup hierarchy then. */
+
+        if (u->load_state != UNIT_LOADED)
+                return 0;
 
         c = unit_get_cgroup_context(u);
         if (!c)