]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: really skip automatic restart when a JOB_STOP job is pending
authorFranck Bui <fbui@suse.com>
Fri, 18 Feb 2022 09:06:24 +0000 (10:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Feb 2022 10:45:12 +0000 (11:45 +0100)
It's not clear why we rescheduled a service auto restart while a stop job for
the unit was pending. The comment claims that the unit shouldn't be restarted
but the code did reschedule an auto restart meanwhile.

In practice that was rarely an issue because the service waited for the next
auto restart to be rescheduled, letting the queued stop job to be proceed and
service_stop() to be called preventing the next restart to complete.

However when RestartSec=0, the timer expired right away making PID1 to
reschedule the unit again, making the timer expired right away... and so
on. This busy loop prevented PID1 to handle any queued jobs (and hence giving
no chance to the start rate limiting to trigger), which made the busy loop last
forever.

This patch breaks this loop by skipping the reschedule of the unit auto restart
and hence not depending on the value of u->restart_usec anymore.

Fixes: #13667
src/core/service.c

index 785038e00852f5c93529bdabfada11db6e110036..6350c564c600a9b47bc278e7ae5d52dd72a29ffb 100644 (file)
@@ -2375,12 +2375,7 @@ static void service_enter_restart(Service *s) {
 
         if (unit_has_job_type(UNIT(s), JOB_STOP)) {
                 /* Don't restart things if we are going down anyway */
-                log_unit_info(UNIT(s), "Stop job pending for unit, delaying automatic restart.");
-
-                r = service_arm_timer(s, usec_add(now(CLOCK_MONOTONIC), s->restart_usec));
-                if (r < 0)
-                        goto fail;
-
+                log_unit_info(UNIT(s), "Stop job pending for unit, skipping automatic restart.");
                 return;
         }