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