]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Delay start rate limit check when starting a unit
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 19 Oct 2021 09:45:48 +0000 (10:45 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 30 Oct 2021 21:13:45 +0000 (22:13 +0100)
Doing start rate limit checks before doing condition checks made
condition check failures count towards the start rate limit which
broke existing assumptions (see #21025). Run the rate limit checks
after the condition checks again to restore the previous behaviour.

src/core/unit.c

index a2944c19176a29fcc7401cbb37950462cb889b1a..a6403002a6fd6b1f3a72f9f6eab25ed446edb7b0 100644 (file)
@@ -1855,13 +1855,6 @@ int unit_start(Unit *u) {
 
         assert(u);
 
-        /* Check start rate limiting early so that failure conditions don't cause us to enter a busy loop. */
-        if (UNIT_VTABLE(u)->test_start_limit) {
-                r = UNIT_VTABLE(u)->test_start_limit(u);
-                if (r < 0)
-                        return r;
-        }
-
         /* If this is already started, then this will succeed. Note that this will even succeed if this unit
          * is not startable by the user. This is relied on to detect when we need to wait for units and when
          * waiting is finished. */
@@ -1911,6 +1904,13 @@ int unit_start(Unit *u) {
                 return unit_start(following);
         }
 
+        /* Check start rate limiting early so that failure conditions don't cause us to enter a busy loop. */
+        if (UNIT_VTABLE(u)->test_start_limit) {
+                r = UNIT_VTABLE(u)->test_start_limit(u);
+                if (r < 0)
+                        return r;
+        }
+
         /* If it is stopped, but we cannot start it, then fail */
         if (!UNIT_VTABLE(u)->start)
                 return -EBADR;