Zbigniew Jędrzejewski-Szmek f1004d
From 6041a7ee2c1bbff6301082f192fc1b0882400d42 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek f1004d
From: Michal Schmidt <mschmidt@redhat.com>
Zbigniew Jędrzejewski-Szmek f1004d
Date: Thu, 9 Oct 2014 17:27:57 +0200
Zbigniew Jędrzejewski-Szmek f1004d
Subject: [PATCH] service: enter SERVICE_STOP_SIGTERM state after getting
Zbigniew Jędrzejewski-Szmek f1004d
 "STOPPING=1"
Zbigniew Jędrzejewski-Szmek f1004d
Zbigniew Jędrzejewski-Szmek f1004d
SERVICE_STOP would mean we're running the ExecStop command. That's not
Zbigniew Jędrzejewski-Szmek f1004d
the case with "STOPPING=1".
Zbigniew Jędrzejewski-Szmek f1004d
Instead we should enter the same state as if we just told the service
Zbigniew Jędrzejewski-Szmek f1004d
to stop, i.e. SERVICE_STOP_SIGTERM.
Zbigniew Jędrzejewski-Szmek f1004d
Zbigniew Jędrzejewski-Szmek f1004d
This fixes a bug where voluntarily exiting services would hang around in
Zbigniew Jędrzejewski-Szmek f1004d
deactivating state until timeout.
Zbigniew Jędrzejewski-Szmek f1004d
---
Zbigniew Jędrzejewski-Szmek f1004d
 src/core/service.c | 3 ++-
Zbigniew Jędrzejewski-Szmek f1004d
 1 file changed, 2 insertions(+), 1 deletion(-)
Zbigniew Jędrzejewski-Szmek f1004d
Zbigniew Jędrzejewski-Szmek f1004d
diff --git a/src/core/service.c b/src/core/service.c
Zbigniew Jędrzejewski-Szmek f1004d
index 395e0ca8c6..f551061366 100644
Zbigniew Jędrzejewski-Szmek f1004d
--- a/src/core/service.c
Zbigniew Jędrzejewski-Szmek f1004d
+++ b/src/core/service.c
Zbigniew Jędrzejewski-Szmek f1004d
@@ -1227,7 +1227,8 @@ static void service_enter_stop_by_notify(Service *s) {
Zbigniew Jędrzejewski-Szmek f1004d
         if (s->timeout_stop_usec > 0)
Zbigniew Jędrzejewski-Szmek f1004d
                 service_arm_timer(s, s->timeout_stop_usec);
Zbigniew Jędrzejewski-Szmek f1004d
 
Zbigniew Jędrzejewski-Szmek f1004d
-        service_set_state(s, SERVICE_STOP);
Zbigniew Jędrzejewski-Szmek f1004d
+        /* The service told us it's stopping, so it's as if we SIGTERM'd it. */
Zbigniew Jędrzejewski-Szmek f1004d
+        service_set_state(s, SERVICE_STOP_SIGTERM);
Zbigniew Jędrzejewski-Szmek f1004d
 }
Zbigniew Jędrzejewski-Szmek f1004d
 
Zbigniew Jędrzejewski-Szmek f1004d
 static void service_enter_stop(Service *s, ServiceResult f) {