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