ryantimwilson / rpms / systemd

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