]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: always coldplug units that are triggered by other units before those
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Apr 2015 14:04:50 +0000 (16:04 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 24 Apr 2015 14:14:46 +0000 (16:14 +0200)
Let's make sure that we don't enqueue triggering jobs for units before
those units are actually fully loaded.

http://lists.freedesktop.org/archives/systemd-devel/2015-April/031176.html
https://bugs.freedesktop.org/show_bug.cgi?id=88401

src/core/unit.c
src/core/unit.h

index 70a2b57fa3dd8aefe3a3c9096c3d5d0a0c802776..2b356e28548f02018906dcc67b0570db906a3915 100644 (file)
@@ -2876,13 +2876,32 @@ int unit_add_node_link(Unit *u, const char *what, bool wants) {
 }
 
 int unit_coldplug(Unit *u) {
+        Unit *other;
+        Iterator i;
         int r;
 
         assert(u);
 
-        if (UNIT_VTABLE(u)->coldplug)
-                if ((r = UNIT_VTABLE(u)->coldplug(u)) < 0)
+        /* Make sure we don't enter a loop, when coldplugging
+         * recursively. */
+        if (u->coldplugged)
+                return 0;
+
+        u->coldplugged = true;
+
+        /* Make sure everything that we might pull in through
+         * triggering is coldplugged before us */
+        SET_FOREACH(other, u->dependencies[UNIT_TRIGGERS], i) {
+                r = unit_coldplug(other);
+                if (r < 0)
                         return r;
+        }
+
+        if (UNIT_VTABLE(u)->coldplug) {
+                r = UNIT_VTABLE(u)->coldplug(u);
+                if (r < 0)
+                        return r;
+        }
 
         if (u->job) {
                 r = job_coldplug(u->job);
index be306a004b809b0bfc8952e69a72daf72d97440b..1a44271bc61a2824c54c245ba91ad9acbf0ee3ac 100644 (file)
@@ -104,6 +104,7 @@ struct Unit {
         char *fragment_path; /* if loaded from a config file this is the primary path to it */
         char *source_path; /* if converted, the source file */
         char **dropin_paths;
+
         usec_t fragment_mtime;
         usec_t source_mtime;
         usec_t dropin_mtime;
@@ -233,6 +234,9 @@ struct Unit {
         bool cgroup_realized:1;
         bool cgroup_members_mask_valid:1;
         bool cgroup_subtree_mask_valid:1;
+
+        /* Did we already invoke unit_coldplug() for this unit? */
+        bool coldplugged;
 };
 
 struct UnitStatusMessageFormats {