teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0768-core-Delay-start-rate-limit-check-when-starting-a-un.patch

8f24f2
From 8c81776212d0aa44f5ae20635079bd6ce76d16ac Mon Sep 17 00:00:00 2001
8f24f2
From: Daan De Meyer <daan.j.demeyer@gmail.com>
8f24f2
Date: Tue, 19 Oct 2021 10:45:48 +0100
8f24f2
Subject: [PATCH] core: Delay start rate limit check when starting a unit
8f24f2
8f24f2
Doing start rate limit checks before doing condition checks made
8f24f2
condition check failures count towards the start rate limit which
8f24f2
broke existing assumptions (see #21025). Run the rate limit checks
8f24f2
after the condition checks again to restore the previous behaviour.
8f24f2
8f24f2
(cherry picked from commit ce2146f5256659c7fb53a7d5b9dc551252e27e7e)
8f24f2
8f24f2
Related: #2065322
8f24f2
---
8f24f2
 src/core/unit.c | 14 +++++++-------
8f24f2
 1 file changed, 7 insertions(+), 7 deletions(-)
8f24f2
8f24f2
diff --git a/src/core/unit.c b/src/core/unit.c
8f24f2
index 4fd9af87b7..b825e2418c 100644
8f24f2
--- a/src/core/unit.c
8f24f2
+++ b/src/core/unit.c
8f24f2
@@ -1729,13 +1729,6 @@ int unit_start(Unit *u) {
8f24f2
 
8f24f2
         assert(u);
8f24f2
 
8f24f2
-        /* Check our ability to start early so that failure conditions don't cause us to enter a busy loop. */
8f24f2
-        if (UNIT_VTABLE(u)->can_start) {
8f24f2
-                r = UNIT_VTABLE(u)->can_start(u);
8f24f2
-                if (r < 0)
8f24f2
-                        return r;
8f24f2
-        }
8f24f2
-
8f24f2
         /* If this is already started, then this will succeed. Note that this will even succeed if this unit
8f24f2
          * is not startable by the user. This is relied on to detect when we need to wait for units and when
8f24f2
          * waiting is finished. */
8f24f2
@@ -1790,6 +1783,13 @@ int unit_start(Unit *u) {
8f24f2
                 return unit_start(following);
8f24f2
         }
8f24f2
 
8f24f2
+        /* Check start rate limiting early so that failure conditions don't cause us to enter a busy loop. */
8f24f2
+        if (UNIT_VTABLE(u)->can_start) {
8f24f2
+                r = UNIT_VTABLE(u)->can_start(u);
8f24f2
+                if (r < 0)
8f24f2
+                        return r;
8f24f2
+        }
8f24f2
+
8f24f2
         /* If it is stopped, but we cannot start it, then fail */
8f24f2
         if (!UNIT_VTABLE(u)->start)
8f24f2
                 return -EBADR;