923a60
From 33de2536b02351fecdae931b19e9980d0cecffbb Mon Sep 17 00:00:00 2001
923a60
From: Lennart Poettering <lennart@poettering.net>
923a60
Date: Sat, 26 Aug 2017 15:07:23 +0200
923a60
Subject: [PATCH] core: disable the effect of Restart= if there's a stop job
923a60
 pending for a service (#6581)
923a60
923a60
We shouldn't undo the job already enqueued, under any circumstances.
923a60
923a60
Fixes: #6504
923a60
(cherry picked from commit 0f52f8e552f869269f02f0359c2d1019cc39f15a)
923a60
923a60
Resolves: #1626382
923a60
---
923a60
 src/core/service.c | 6 ++++++
923a60
 1 file changed, 6 insertions(+)
923a60
923a60
diff --git a/src/core/service.c b/src/core/service.c
923a60
index 8303a1e7ee..4d542ad947 100644
923a60
--- a/src/core/service.c
923a60
+++ b/src/core/service.c
923a60
@@ -1271,8 +1271,14 @@ static int cgroup_good(Service *s) {
923a60
 
923a60
 static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart) {
923a60
         int r;
923a60
+
923a60
         assert(s);
923a60
 
923a60
+        /* If there's a stop job queued before we enter the DEAD state, we shouldn't act on Restart=, in order to not
923a60
+         * undo what has already been enqueued. */
923a60
+        if (unit_stop_pending(UNIT(s)))
923a60
+                allow_restart = false;
923a60
+
923a60
         if (f != SERVICE_SUCCESS)
923a60
                 s->result = f;
923a60