803fb7
From 7f72b471bbfd449f4261d12cc7b062f6e7034283 Mon Sep 17 00:00:00 2001
803fb7
From: Lennart Poettering <lennart@poettering.net>
803fb7
Date: Tue, 19 May 2015 17:40:50 +0200
803fb7
Subject: [PATCH] core: reinstate propagation of stop/restart jobs via
803fb7
 RequsiteOf dependencies
803fb7
803fb7
This reverts the primary effect of be7d9ff730cb88d7c6a869dd5c47754c78ceaef2.
803fb7
803fb7
After all Requisite= should be close to Requires=, without the one
803fb7
exception that it doesn't pull in dependencies on start. However,
803fb7
reverse deps on stop/restart should be treated the same way as for
803fb7
Restart=, and this is already documented in the man page, hence stick to
803fb7
it.
803fb7
803fb7
http://lists.freedesktop.org/archives/systemd-devel/2015-May/032049.html
803fb7
(cherry picked from commit ce74e76920dca603a12ef4bf605567965e9e7e45)
803fb7
803fb7
[msekleta: we didn't backport be7d9ff730cb88d7c6a869dd5c47754c78ceaef2
803fb7
and hence we don't have UNIT_REQUISITE_OF. Note that this patch was
803fb7
backported because it makes backports of followup patches easier]
803fb7
803fb7
Related: #1436021
803fb7
---
803fb7
 src/core/transaction.c | 41 +++++++++++++----------------------------
803fb7
 1 file changed, 13 insertions(+), 28 deletions(-)
803fb7
803fb7
diff --git a/src/core/transaction.c b/src/core/transaction.c
803fb7
index 57e9cb3f8..428b7671b 100644
803fb7
--- a/src/core/transaction.c
803fb7
+++ b/src/core/transaction.c
803fb7
@@ -1008,40 +1008,25 @@ int transaction_add_job_and_dependencies(
803fb7
                 }
803fb7
 
803fb7
                 if (type == JOB_STOP || type == JOB_RESTART) {
803fb7
+                        static const UnitDependency propagate_deps[] = {
803fb7
+                                UNIT_REQUIRED_BY,
803fb7
+                                UNIT_BOUND_BY,
803fb7
+                                UNIT_CONSISTS_OF,
803fb7
+                        };
803fb7
 
803fb7
-                        SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRED_BY], i) {
803fb7
-                                r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
803fb7
-                                if (r < 0) {
803fb7
-                                        if (r != -EBADR)
803fb7
-                                                goto fail;
803fb7
-
803fb7
-                                        if (e)
803fb7
-                                                sd_bus_error_free(e);
803fb7
-                                }
803fb7
-                        }
803fb7
-
803fb7
-                        SET_FOREACH(dep, ret->unit->dependencies[UNIT_BOUND_BY], i) {
803fb7
-                                r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
803fb7
-                                if (r < 0) {
803fb7
-                                        if (r != -EBADR)
803fb7
-                                                goto fail;
803fb7
+                        unsigned j;
803fb7
 
803fb7
-                                        if (e)
803fb7
-                                                sd_bus_error_free(e);
803fb7
-                                }
803fb7
-                        }
803fb7
+                        for (j = 0; j < ELEMENTSOF(propagate_deps); j++)
803fb7
+                                SET_FOREACH(dep, ret->unit->dependencies[propagate_deps[j]], i) {
803fb7
 
803fb7
-                        SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONSISTS_OF], i) {
803fb7
-                                r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
803fb7
-                                if (r < 0) {
803fb7
-                                        if (r != -EBADR)
803fb7
-                                                goto fail;
803fb7
+                                        r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
803fb7
+                                        if (r < 0) {
803fb7
+                                                if (r != -EBADR)
803fb7
+                                                        goto fail;
803fb7
 
803fb7
-                                        if (e)
803fb7
                                                 sd_bus_error_free(e);
803fb7
+                                        }
803fb7
                                 }
803fb7
-                        }
803fb7
-
803fb7
                 }
803fb7
 
803fb7
                 if (type == JOB_RELOAD) {