]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: allow services stuck in reloading state to exit
authorPeter Morrow <pemorrow@linux.microsoft.com>
Tue, 13 Apr 2021 16:20:42 +0000 (17:20 +0100)
committerPeter Morrow <pemorrow@linux.microsoft.com>
Thu, 22 Apr 2021 08:28:50 +0000 (09:28 +0100)
If a service is in reloading state but has exited do not delay
the final exit until the service reload timer expires. Instead allow
the service to exit immediately since we can't expect the service to
ever transition out of reloading state.

For example if a service sent RELOADING=1 but crashed before it could
send READY=1 then it should be restarted if the service had
Restart= configured.

Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
src/core/service.c

index fb97bbeaae0b3088d768b5af45866d4454770eda..d5f79d274efbe4f4a94145a517ce9455cac45b16 100644 (file)
@@ -3474,6 +3474,15 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
 
                         case SERVICE_START_POST:
                         case SERVICE_RELOAD:
+                                /* If neither main nor control processes are running then
+                                 * the current state can never exit cleanly, hence immediately
+                                 * terminate the service. */
+                                if (control_pid_good(s) <= 0)
+                                        service_enter_stop(s, f);
+
+                                /* Otherwise need to wait untill the operation is done. */
+                                break;
+
                         case SERVICE_STOP:
                                 /* Need to wait until the operation is
                                  * done */