naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
9fc0f6
From bb586b571661bd77cafe0824efecdba502c99a98 Mon Sep 17 00:00:00 2001
9fc0f6
From: Lennart Poettering <lennart@poettering.net>
9fc0f6
Date: Thu, 13 Feb 2014 02:12:27 +0100
9fc0f6
Subject: [PATCH] core: make StopWhenUnneeded work in conjunction with units
9fc0f6
 that fail during their start job
9fc0f6
9fc0f6
https://bugzilla.redhat.com/show_bug.cgi?id=997031
9fc0f6
9fc0f6
Resolves: #986949
9fc0f6
---
9fc0f6
 src/core/unit.c | 9 +++++----
9fc0f6
 1 file changed, 5 insertions(+), 4 deletions(-)
9fc0f6
9fc0f6
diff --git a/src/core/unit.c b/src/core/unit.c
9fc0f6
index a4e6c18..17792d1 100644
9fc0f6
--- a/src/core/unit.c
9fc0f6
+++ b/src/core/unit.c
9fc0f6
@@ -1455,7 +1455,9 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
9fc0f6
          * sucessfully, since there's no change of state in that case. Which is
9fc0f6
          * why it is handled in service_set_state() */
9fc0f6
         if (UNIT_IS_INACTIVE_OR_FAILED(os) != UNIT_IS_INACTIVE_OR_FAILED(ns)) {
9fc0f6
-                ExecContext *ec = unit_get_exec_context(u);
9fc0f6
+                ExecContext *ec;
9fc0f6
+
9fc0f6
+                ec = unit_get_exec_context(u);
9fc0f6
                 if (ec && exec_context_may_touch_console(ec)) {
9fc0f6
                         if (UNIT_IS_INACTIVE_OR_FAILED(ns)) {
9fc0f6
                                 m->n_on_console --;
9fc0f6
@@ -1551,12 +1553,11 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
9fc0f6
                 }
9fc0f6
 
9fc0f6
                 /* stop unneeded units regardless if going down was expected or not */
9fc0f6
-                if (UNIT_IS_ACTIVE_OR_ACTIVATING(os) && UNIT_IS_INACTIVE_OR_DEACTIVATING(ns))
9fc0f6
+                if (UNIT_IS_INACTIVE_OR_DEACTIVATING(ns))
9fc0f6
                         check_unneeded_dependencies(u);
9fc0f6
 
9fc0f6
                 if (ns != os && ns == UNIT_FAILED) {
9fc0f6
-                        log_notice_unit(u->id,
9fc0f6
-                                        "Unit %s entered failed state.", u->id);
9fc0f6
+                        log_notice_unit(u->id, "Unit %s entered failed state.", u->id);
9fc0f6
                         unit_start_on_failure(u);
9fc0f6
                 }
9fc0f6
         }