diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-09-11 19:57:09 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-09-14 13:05:09 +0200 |
commit | 47ab8f73e3468b6e5a48218eacdb830e978d2cfd (patch) | |
tree | c16aa5048b03c0af285888b2a83593a882f9f9aa /src/core/path.c | |
parent | 0377cd2936ae5cac0c9d76a4b58889f121c097c4 (diff) | |
download | systemd-47ab8f73e3468b6e5a48218eacdb830e978d2cfd.tar.gz |
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: #16669
Diffstat (limited to 'src/core/path.c')
-rw-r--r-- | src/core/path.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/path.c b/src/core/path.c index 8ffec72ede..4f4e7100cf 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -753,6 +753,20 @@ static void path_trigger_notify(Unit *u, Unit *other) { /* Filter out invocations with bogus state */ assert(UNIT_IS_LOAD_COMPLETE(other->load_state)); + /* Don't propagate state changes from the triggered unit if we are already down */ + if (!IN_SET(p->state, PATH_WAITING, PATH_RUNNING)) + return; + + /* Propagate start limit hit state */ + if (other->start_limit_hit) { + path_enter_dead(p, PATH_FAILURE_UNIT_START_LIMIT_HIT); + return; + } + + /* Don't propagate anything if there's still a job queued */ + if (other->job) + return; + if (p->state == PATH_RUNNING && UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) { log_unit_debug(UNIT(p), "Got notified about unit deactivation."); @@ -789,6 +803,7 @@ static const char* const path_result_table[_PATH_RESULT_MAX] = { [PATH_SUCCESS] = "success", [PATH_FAILURE_RESOURCES] = "resources", [PATH_FAILURE_START_LIMIT_HIT] = "start-limit-hit", + [PATH_FAILURE_UNIT_START_LIMIT_HIT] = "unit-start-limit-hit", }; DEFINE_STRING_TABLE_LOOKUP(path_result, PathResult); |