ryantimwilson / rpms / systemd

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