|
|
68bdd43 |
From cd0504d0a13d8297b97c9238fd1b94b4141c5aa8 Mon Sep 17 00:00:00 2001
|
|
|
68bdd43 |
From: Michal Schmidt <mschmidt@redhat.com>
|
|
|
68bdd43 |
Date: Fri, 9 Dec 2011 15:25:29 +0100
|
|
|
68bdd43 |
Subject: [PATCH 2/2] unit: check for unneeded dependencies even when unit
|
|
|
68bdd43 |
stop was expected
|
|
|
68bdd43 |
|
|
|
68bdd43 |
systemd did not stop units marked as "StopWhenUnneeded=yes" when the requiring
|
|
|
68bdd43 |
unit was stopped on user's request.
|
|
|
68bdd43 |
|
|
|
68bdd43 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=704197
|
|
|
68bdd43 |
---
|
|
|
68bdd43 |
src/unit.c | 12 ++++++++++++
|
|
|
68bdd43 |
1 files changed, 12 insertions(+), 0 deletions(-)
|
|
|
68bdd43 |
|
|
|
68bdd43 |
diff --git a/src/unit.c b/src/unit.c
|
|
|
68bdd43 |
index 56137d7..03c90f5 100644
|
|
|
68bdd43 |
--- a/src/unit.c
|
|
|
68bdd43 |
+++ b/src/unit.c
|
|
|
68bdd43 |
@@ -1105,6 +1105,14 @@ static void retroactively_stop_dependencies(Unit *u) {
|
|
|
68bdd43 |
SET_FOREACH(other, u->meta.dependencies[UNIT_BOUND_BY], i)
|
|
|
68bdd43 |
if (!UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(other)))
|
|
|
68bdd43 |
manager_add_job(u->meta.manager, JOB_STOP, other, JOB_REPLACE, true, NULL, NULL);
|
|
|
68bdd43 |
+}
|
|
|
68bdd43 |
+
|
|
|
68bdd43 |
+static void check_unneeded_dependencies(Unit *u) {
|
|
|
68bdd43 |
+ Iterator i;
|
|
|
68bdd43 |
+ Unit *other;
|
|
|
68bdd43 |
+
|
|
|
68bdd43 |
+ assert(u);
|
|
|
68bdd43 |
+ assert(UNIT_IS_INACTIVE_OR_DEACTIVATING(unit_active_state(u)));
|
|
|
68bdd43 |
|
|
|
68bdd43 |
/* Garbage collect services that might not be needed anymore, if enabled */
|
|
|
68bdd43 |
SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRES], i)
|
|
|
68bdd43 |
@@ -1263,6 +1271,10 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
|
|
|
68bdd43 |
retroactively_stop_dependencies(u);
|
|
|
68bdd43 |
}
|
|
|
68bdd43 |
|
|
|
68bdd43 |
+ /* stop unneeded units regardless if going down was expected or not */
|
|
|
68bdd43 |
+ if (UNIT_IS_ACTIVE_OR_ACTIVATING(os) && UNIT_IS_INACTIVE_OR_DEACTIVATING(ns))
|
|
|
68bdd43 |
+ check_unneeded_dependencies(u);
|
|
|
68bdd43 |
+
|
|
|
68bdd43 |
if (ns != os && ns == UNIT_FAILED) {
|
|
|
68bdd43 |
log_notice("Unit %s entered failed state.", u->meta.id);
|
|
|
68bdd43 |
unit_trigger_on_failure(u);
|
|
|
68bdd43 |
--
|
|
|
68bdd43 |
1.7.7.5
|
|
|
68bdd43 |
|