ryantimwilson / rpms / systemd

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