[systemd-commits] 3 commits - src/core units/systemd-importd.service.in units/systemd-udevd.service.in

Lennart Poettering lennart at kemper.freedesktop.org
Fri Apr 24 07:18:12 PDT 2015


 src/core/manager.c               |   21 +++++++--------------
 src/core/unit.c                  |   23 +++++++++++++++++++++--
 src/core/unit.h                  |    4 ++++
 units/systemd-importd.service.in |    1 +
 units/systemd-udevd.service.in   |    1 +
 5 files changed, 34 insertions(+), 16 deletions(-)

New commits:
commit 658f26b828fdd7007cfe82d794f610525b21cb99
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 24 16:12:28 2015 +0200

    units: set KillMode=mixed for our daemons that fork worker processes
    
    The daemons should really have the time to kill the workers first,
    before systemd does it, hence use KillMode=mixed for these daemons.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=90051

diff --git a/units/systemd-importd.service.in b/units/systemd-importd.service.in
index 80d97c8..403f153 100644
--- a/units/systemd-importd.service.in
+++ b/units/systemd-importd.service.in
@@ -15,3 +15,4 @@ BusName=org.freedesktop.import1
 CapabilityBoundingSet=CAP_CHOWN CAP_FOWNER CAP_FSETID CAP_MKNOD CAP_SETFCAP CAP_SYS_ADMIN CAP_SETPCAP CAP_DAC_OVERRIDE
 NoNewPrivileges=yes
 WatchdogSec=1min
+KillMode=mixed
diff --git a/units/systemd-udevd.service.in b/units/systemd-udevd.service.in
index a133044..32f04d9 100644
--- a/units/systemd-udevd.service.in
+++ b/units/systemd-udevd.service.in
@@ -22,3 +22,4 @@ Restart=always
 RestartSec=0
 ExecStart=@rootlibexecdir@/systemd-udevd
 MountFlags=slave
+KillMode=mixed

commit 007c6337c6ddf2eb1e7db4d9cd00b044d6d8e165
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 24 16:09:15 2015 +0200

    manager: don't fail fatally if we cannot coldplug a unit
    
    It's better to continue as good as we can, than to totally fail. Hence,
    let's log about the failure and continue.

diff --git a/src/core/manager.c b/src/core/manager.c
index 39a868f..f13dad5 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -975,28 +975,25 @@ int manager_enumerate(Manager *m) {
         return r;
 }
 
-static int manager_coldplug(Manager *m) {
-        int r = 0;
+static void manager_coldplug(Manager *m) {
         Iterator i;
         Unit *u;
         char *k;
+        int r;
 
         assert(m);
 
         /* Then, let's set up their initial state. */
         HASHMAP_FOREACH_KEY(u, k, m->units, i) {
-                int q;
 
                 /* ignore aliases */
                 if (u->id != k)
                         continue;
 
-                q = unit_coldplug(u);
-                if (q < 0)
-                        r = q;
+                r = unit_coldplug(u);
+                if (r < 0)
+                        log_warning_errno(r, "We couldn't coldplug %s, proceeding anyway: %m", u->id);
         }
-
-        return r;
 }
 
 static void manager_build_unit_path_cache(Manager *m) {
@@ -1140,9 +1137,7 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
         bus_track_coldplug(m, &m->subscribed, &m->deserialized_subscribed);
 
         /* Third, fire things up! */
-        q = manager_coldplug(m);
-        if (q < 0 && r == 0)
-                r = q;
+        manager_coldplug(m);
 
         if (serialization) {
                 assert(m->n_reloading > 0);
@@ -2560,9 +2555,7 @@ int manager_reload(Manager *m) {
                 r = q;
 
         /* Third, fire things up! */
-        q = manager_coldplug(m);
-        if (q < 0 && r >= 0)
-                r = q;
+        manager_coldplug(m);
 
         assert(m->n_reloading > 0);
         m->n_reloading--;

commit f78f265f405a61387c6c12a879ac0d6b6dc958db
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Apr 24 16:04:50 2015 +0200

    core: always coldplug units that are triggered by other units before those
    
    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

diff --git a/src/core/unit.c b/src/core/unit.c
index 70a2b57..2b356e2 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -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);
diff --git a/src/core/unit.h b/src/core/unit.h
index be306a0..1a44271 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -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 {



More information about the systemd-commits mailing list