chiark / gitweb /
dbus: don't rely that timer/path units have an initialized unit field
[elogind.git] / src / unit.c
index bfb1dd644ebb62013d7f98cd23e112b9998f504b..0d5312376c2b547234dafce07349b5cd526ca8d0 100644 (file)
@@ -556,8 +556,12 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
 
         if (c->std_output != EXEC_OUTPUT_KMSG &&
             c->std_output != EXEC_OUTPUT_SYSLOG &&
+            c->std_output != EXEC_OUTPUT_KMSG_AND_CONSOLE &&
+            c->std_output != EXEC_OUTPUT_SYSLOG_AND_CONSOLE &&
             c->std_error != EXEC_OUTPUT_KMSG &&
-            c->std_error != EXEC_OUTPUT_SYSLOG)
+            c->std_error != EXEC_OUTPUT_SYSLOG_AND_CONSOLE &&
+            c->std_error != EXEC_OUTPUT_KMSG &&
+            c->std_error != EXEC_OUTPUT_SYSLOG_AND_CONSOLE)
                 return 0;
 
         /* If syslog or kernel logging is requested, make sure our own
@@ -1067,7 +1071,7 @@ static void retroactively_stop_dependencies(Unit *u) {
                         unit_check_unneeded(other);
 }
 
-void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) {
+void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success) {
         dual_timestamp ts;
         bool unexpected;
 
@@ -1134,7 +1138,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) {
 
                         if (u->meta.job->state == JOB_RUNNING) {
                                 if (ns == UNIT_ACTIVE)
-                                        job_finish_and_invalidate(u->meta.job, true);
+                                        job_finish_and_invalidate(u->meta.job, reload_success);
                                 else if (ns != UNIT_ACTIVATING && ns != UNIT_RELOADING) {
                                         unexpected = true;
 
@@ -1194,7 +1198,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) {
                         /* The bus just might have become available,
                          * hence try to connect to it, if we aren't
                          * yet connected. */
-                        bus_init(u->meta.manager);
+                        bus_init(u->meta.manager, true);
 
                 if (unit_has_name(u, SPECIAL_SYSLOG_SERVICE))
                         /* The syslog daemon just might have become
@@ -1785,55 +1789,61 @@ fail:
         return r;
 }
 
-int unit_add_default_cgroups(Unit *u) {
+static int unit_add_one_default_cgroup(Unit *u, const char *controller) {
         CGroupBonding *b = NULL;
         int r = -ENOMEM;
-        const char * const default_controllers[] = {
-                SYSTEMD_CGROUP_CONTROLLER,
-                "cpu",
-                NULL
-        };
-        const char * const*c;
 
         assert(u);
 
-        /* Adds in the default cgroups, if it wasn't specified yet */
-
-        STRV_FOREACH(c, default_controllers) {
-
-                if (cgroup_bonding_find_list(u->meta.cgroup_bondings, *c))
-                        continue;
+        if (!controller)
+                controller = SYSTEMD_CGROUP_CONTROLLER;
 
-                if (!(b = new0(CGroupBonding, 1)))
-                        return -ENOMEM;
+        if (cgroup_bonding_find_list(u->meta.cgroup_bondings, controller))
+                return 0;
 
-                if (!(b->path = default_cgroup_path(u)))
-                        goto fail;
+        if (!(b = new0(CGroupBonding, 1)))
+                return -ENOMEM;
 
-                if (!(b->controller = strdup(*c)))
-                        goto fail;
+        if (!(b->controller = strdup(controller)))
+                goto fail;
 
-                b->ours = true;
-                b->essential = c == default_controllers; /* the first one is essential */
+        if (!(b->path = default_cgroup_path(u)))
+                goto fail;
 
-                if ((r = unit_add_cgroup(u, b)) < 0)
-                        goto fail;
+        b->ours = true;
+        b->essential = streq(controller, SYSTEMD_CGROUP_CONTROLLER);
 
-                b = NULL;
-        }
+        if ((r = unit_add_cgroup(u, b)) < 0)
+                goto fail;
 
         return 0;
 
 fail:
-        if (b) {
-                free(b->path);
-                free(b->controller);
-                free(b);
-        }
+        free(b->path);
+        free(b->controller);
+        free(b);
 
         return r;
 }
 
+int unit_add_default_cgroups(Unit *u) {
+        char **c;
+        int r;
+        assert(u);
+
+        /* Adds in the default cgroups, if they weren't specified
+         * otherwise. */
+
+        if ((r = unit_add_one_default_cgroup(u, NULL)) < 0)
+                return r;
+
+        STRV_FOREACH(c, u->meta.manager->default_controllers)
+                if ((r = unit_add_one_default_cgroup(u, *c)) < 0)
+                        return r;
+
+        return 0;
+}
+
 CGroupBonding* unit_get_default_cgroup(Unit *u) {
         assert(u);