Skip to content
This repository was archived by the owner on Nov 15, 2025. It is now read-only.

Commit 689d2e0

Browse files
poetteringkeszybz
authored andcommitted
core: propagate unit start limit hit state to triggering path unit
We already do this for socket and automount units, do it for path units too: if the triggered service keeps hitting the start limit, then fail the triggering unit too, so that we don#t busy loop forever. (Note that this leaves only timer units out in the cold for this kind of protection, but it shouldn't matter there, as they are naturally protected against busy loops: they are scheduled by time anyway). Fixes: systemd#16669 (cherry picked from commit 47ab8f7)
1 parent 2f53d69 commit 689d2e0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/core/path.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,20 @@ static void path_trigger_notify(Unit *u, Unit *other) {
753753
/* Filter out invocations with bogus state */
754754
assert(UNIT_IS_LOAD_COMPLETE(other->load_state));
755755

756+
/* Don't propagate state changes from the triggered unit if we are already down */
757+
if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING))
758+
return;
759+
760+
/* Propagate start limit hit state */
761+
if (other->start_limit_hit) {
762+
path_enter_dead(p, PATH_FAILURE_UNIT_START_LIMIT_HIT);
763+
return;
764+
}
765+
766+
/* Don't propagate anything if there's still a job queued */
767+
if (other->job)
768+
return;
769+
756770
if (p->state == PATH_RUNNING &&
757771
UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
758772
log_unit_debug(UNIT(p), "Got notified about unit deactivation.");
@@ -789,6 +803,7 @@ static const char* const path_result_table[_PATH_RESULT_MAX] = {
789803
[PATH_SUCCESS] = "success",
790804
[PATH_FAILURE_RESOURCES] = "resources",
791805
[PATH_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
806+
[PATH_FAILURE_UNIT_START_LIMIT_HIT] = "unit-start-limit-hit",
792807
};
793808

794809
DEFINE_STRING_TABLE_LOOKUP(path_result, PathResult);

src/core/path.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ typedef enum PathResult {
4545
PATH_SUCCESS,
4646
PATH_FAILURE_RESOURCES,
4747
PATH_FAILURE_START_LIMIT_HIT,
48+
PATH_FAILURE_UNIT_START_LIMIT_HIT,
4849
_PATH_RESULT_MAX,
4950
_PATH_RESULT_INVALID = -1
5051
} PathResult;

0 commit comments

Comments
 (0)