diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2021-08-24 16:46:47 +0100 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2021-08-25 13:26:14 +0100 |
commit | 9727f2427ff6b2e1f4ab927cc57ad8e888f04e95 (patch) | |
tree | d145a7fd24306686e49ebed9c9c4c2b53f72a913 /src/core/timer.c | |
parent | a243128d1fcfc378df9fce1b4997148a17ef23a5 (diff) | |
download | systemd-9727f2427ff6b2e1f4ab927cc57ad8e888f04e95.tar.gz |
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.
Diffstat (limited to 'src/core/timer.c')
-rw-r--r-- | src/core/timer.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/core/timer.c b/src/core/timer.c index 12515a6a75..8853121c00 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -627,12 +627,6 @@ static int timer_start(Unit *u) { if (r < 0) return r; - r = unit_test_start_limit(u); - if (r < 0) { - timer_enter_dead(t, TIMER_FAILURE_START_LIMIT_HIT); - return r; - } - r = unit_acquire_invocation_id(u); if (r < 0) return r; @@ -890,6 +884,21 @@ static int timer_can_clean(Unit *u, ExecCleanMask *ret) { return 0; } +static int timer_test_start_limit(Unit *u) { + Timer *t = TIMER(u); + int r; + + assert(t); + + r = unit_test_start_limit(u); + if (r < 0) { + timer_enter_dead(t, TIMER_FAILURE_START_LIMIT_HIT); + return r; + } + + return 0; +} + static const char* const timer_base_table[_TIMER_BASE_MAX] = { [TIMER_ACTIVE] = "OnActiveSec", [TIMER_BOOT] = "OnBootSec", @@ -949,4 +958,6 @@ const UnitVTable timer_vtable = { .timezone_change = timer_timezone_change, .bus_set_property = bus_timer_set_property, + + .test_start_limit = timer_test_start_limit, }; |