richardphibel / rpms / systemd

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