summaryrefslogtreecommitdiff
path: root/src/core/transaction.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-05-19 18:13:22 +0200
committerLennart Poettering <lennart@poettering.net>2015-05-19 18:21:19 +0200
commitc6497ccb7153af9a1252c48918e380b5134314de (patch)
tree00e5106e59779057cd200c1995f5b7b92654aa5b /src/core/transaction.c
parent9ee18af3a036074c4021c82ae2e67f5ccaa9ea9d (diff)
core: when propagating restart requests due to deps, downgrade restart to try-restart
Previously, if a service A depended on a service B via Requires=, and A was not running and B restarted this would trigger a start of A as well, since the restart was propagated as restart independently of the state of A. This patch ensures that a restart of B would be propagated as a try-restart to A, thus not changing its state if it isn't up. http://lists.freedesktop.org/archives/systemd-devel/2015-May/032061.html
Diffstat (limited to 'src/core/transaction.c')
-rw-r--r--src/core/transaction.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/transaction.c b/src/core/transaction.c
index 9817057185..33fa675e53 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -861,8 +861,7 @@ int transaction_add_job_and_dependencies(
/* by ? job_type_to_string(by->type) : "NA"); */
if (!IN_SET(unit->load_state, UNIT_LOADED, UNIT_ERROR, UNIT_NOT_FOUND, UNIT_MASKED))
- return sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED,
- "Unit %s is not loaded properly.", unit->id);
+ return sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->id);
if (type != JOB_STOP && unit->load_state == UNIT_ERROR) {
if (unit->load_error == -ENOENT || unit->manager->test_run)
@@ -1023,12 +1022,18 @@ int transaction_add_job_and_dependencies(
UNIT_CONSISTS_OF,
};
+ JobType ptype;
unsigned j;
+ /* We propagate STOP as STOP, but RESTART only
+ * as TRY_RESTART, in order not to start
+ * dependencies that are not around. */
+ ptype = type == JOB_RESTART ? JOB_TRY_RESTART : type;
+
for (j = 0; j < ELEMENTSOF(propagate_deps); j++)
SET_FOREACH(dep, ret->unit->dependencies[propagate_deps[j]], i) {
- r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
+ r = transaction_add_job_and_dependencies(tr, job_type_collapse(ptype, dep), dep, ret, true, override, false, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR)
goto fail;