summaryrefslogtreecommitdiff
path: root/src/core/job.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/job.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/job.c')
-rw-r--r--src/core/job.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/core/job.c b/src/core/job.c
index 198e3b6423..8a047df0c3 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -388,38 +388,38 @@ bool job_type_is_redundant(JobType a, UnitActiveState b) {
}
}
-void job_type_collapse(JobType *t, Unit *u) {
+JobType job_type_collapse(JobType t, Unit *u) {
UnitActiveState s;
- switch (*t) {
+ switch (t) {
case JOB_TRY_RESTART:
s = unit_active_state(u);
if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s))
- *t = JOB_NOP;
- else
- *t = JOB_RESTART;
- break;
+ return JOB_NOP;
+
+ return JOB_RESTART;
case JOB_RELOAD_OR_START:
s = unit_active_state(u);
if (UNIT_IS_INACTIVE_OR_DEACTIVATING(s))
- *t = JOB_START;
- else
- *t = JOB_RELOAD;
- break;
+ return JOB_START;
+
+ return JOB_RELOAD;
default:
- ;
+ return t;
}
}
int job_type_merge_and_collapse(JobType *a, JobType b, Unit *u) {
- JobType t = job_type_lookup_merge(*a, b);
+ JobType t;
+
+ t = job_type_lookup_merge(*a, b);
if (t < 0)
return -EEXIST;
- *a = t;
- job_type_collapse(a, u);
+
+ *a = job_type_collapse(t, u);
return 0;
}