be0c12
From c667291303bb876707d86ac3ab9ca62355bae1b3 Mon Sep 17 00:00:00 2001
be0c12
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
be0c12
Date: Tue, 16 Oct 2018 22:45:34 +0200
be0c12
Subject: [PATCH] core: consider service with no start command immediately
be0c12
 started
be0c12
be0c12
The service would always be in state == SERVICE_INACTIVE, but it needs to go
be0c12
through state == SERVICE_START so that SuccessAction/FailureAction are executed.
be0c12
be0c12
(cherry picked from commit ef5ae8e71329e43c277e6d4f983f0c0793047b94)
be0c12
be0c12
Related: #1860899
be0c12
---
be0c12
 src/core/service.c | 6 ++++++
be0c12
 1 file changed, 6 insertions(+)
be0c12
be0c12
diff --git a/src/core/service.c b/src/core/service.c
be0c12
index ae31973774..4da1c5accb 100644
be0c12
--- a/src/core/service.c
be0c12
+++ b/src/core/service.c
be0c12
@@ -2055,6 +2055,12 @@ static void service_enter_start(Service *s) {
be0c12
                         goto fail;
be0c12
                 }
be0c12
 
be0c12
+                /* We force a fake state transition here. Otherwise, the unit would go directly from
be0c12
+                 * SERVICE_DEAD to SERVICE_DEAD without SERVICE_ACTIVATING or SERVICE_ACTIVE
be0c12
+                 * inbetween. This way we can later trigger actions that depend on the state
be0c12
+                 * transition, including SuccessAction=. */
be0c12
+                service_set_state(s, SERVICE_START);
be0c12
+
be0c12
                 service_enter_start_post(s);
be0c12
                 return;
be0c12
         }