core: Check unit start rate limiting earlier
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 24 Aug 2021 15:46:47 +0000 (16:46 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Jan 2022 19:41:02 +0000 (20:41 +0100)
commita82b93092bdd3901a22375a820bfa09db8a39978
tree418a292eea92270e84c38c06feea5aebf7e9e571
parent9e29d13926b62c10d931d287b30b7874872bfe39
core: Check unit start rate limiting earlier

Fixes #17433. Currently, if any of the validations we do before we
check start rate limiting fail, we can still enter a busy loop as
no rate limiting gets applied. A common occurence of this scenario
is path units triggering a service that fails a condition check.

To fix the issue, we simply move up start rate limiting checks to
be the first thing we do when starting a unit. To achieve this,
we add a new method to the unit vtable and implement it for the
relevant unit types so that we can do the start rate limit checks
earlier on.

(cherry picked from commit 9727f2427ff6b2e1f4ab927cc57ad8e888f04e95)
16 files changed:
src/core/automount.c
src/core/mount.c
src/core/path.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/timer.c
src/core/unit.c
src/core/unit.h
test/TEST-63-ISSUE-17433/Makefile [new symlink]
test/TEST-63-ISSUE-17433/test.sh [new file with mode: 0755]
test/meson.build
test/testsuite-10.units/test10.service
test/testsuite-63.units/test63.path [new file with mode: 0644]
test/testsuite-63.units/test63.service [new file with mode: 0644]
test/units/testsuite-63.service [new file with mode: 0644]