Blame SOURCES/0448-core-if-the-start-command-vanishes-during-runtime-do.patch

17b0f1
From a66f97acac8b99a49aac58adf6d652cad7e4be38 Mon Sep 17 00:00:00 2001
17b0f1
From: Lennart Poettering <lennart@poettering.net>
17b0f1
Date: Fri, 21 Oct 2016 12:27:46 +0200
17b0f1
Subject: [PATCH] core: if the start command vanishes during runtime don't hit
17b0f1
 an assert
17b0f1
17b0f1
This can happen when the configuration is changed and reloaded while we are
17b0f1
executing a service. Let's not hit an assert in this case.
17b0f1
17b0f1
Fixes: #4444
17b0f1
17b0f1
Cherry-picked from: 47fffb3530af3e3ad4048570611685635fde062e
17b0f1
Resolves: #1421658
17b0f1
---
17b0f1
 src/core/service.c | 10 +++++++++-
17b0f1
 1 file changed, 9 insertions(+), 1 deletion(-)
17b0f1
17b0f1
diff --git a/src/core/service.c b/src/core/service.c
17b0f1
index 6e7baa76c6..84e00573f3 100644
17b0f1
--- a/src/core/service.c
17b0f1
+++ b/src/core/service.c
17b0f1
@@ -1563,7 +1563,15 @@ static void service_enter_start(Service *s) {
17b0f1
         }
17b0f1
 
17b0f1
         if (!c) {
17b0f1
-                assert(s->type == SERVICE_ONESHOT);
17b0f1
+                if (s->type != SERVICE_ONESHOT) {
17b0f1
+                        /* There's no command line configured for the main command? Hmm, that is strange. This can only
17b0f1
+                         * happen if the configuration changes at runtime. In this case, let's enter a failure
17b0f1
+                         * state. */
17b0f1
+                        log_unit_error(UNIT(s), "There's no 'start' task anymore we could start: %m");
17b0f1
+                        r = -ENXIO;
17b0f1
+                        goto fail;
17b0f1
+                }
17b0f1
+
17b0f1
                 service_enter_start_post(s);
17b0f1
                 return;
17b0f1
         }