From: Franck Bui Date: Fri, 18 Feb 2022 09:06:24 +0000 (+0100) Subject: core: really skip automatic restart when a JOB_STOP job is pending X-Git-Tag: v251-rc1~247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c972880640ee19e89ce9265d8eae1b3aae190332;p=thirdparty%2Fsystemd.git core: really skip automatic restart when a JOB_STOP job is pending 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 --- diff --git a/src/core/service.c b/src/core/service.c index 785038e0085..6350c564c60 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -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; }