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)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 5 Mar 2022 21:03:32 +0000 (21:03 +0000)
commit2198c08d0786c5cec1b39283831969b2cc1adf40
treebbb7dcde0254b78cc4868a4e07f1bd9597c320b6
parentd016749c00c4c8e67107d2b9bde1dc97ff5e38d0
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
(cherry picked from commit c972880640ee19e89ce9265d8eae1b3aae190332)
src/core/service.c