diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-02-10 23:39:31 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-02-11 12:02:34 +0100 |
commit | e903182e5b0daa941de47a9c08c824106cec7fe0 (patch) | |
tree | 86c3b440d132e562b3ce02fc22b26ff4266897b2 /src/core/path.c | |
parent | 03a78688056e533390992db8adf304c2b6798088 (diff) |
core: don't choke if a unit another unit triggers vanishes during reload
Fixes: #1981
Diffstat (limited to 'src/core/path.c')
-rw-r--r-- | src/core/path.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/core/path.c b/src/core/path.c index 610901275c..460c1d3bf2 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -464,6 +464,7 @@ static void path_enter_dead(Path *p, PathResult f) { static void path_enter_running(Path *p) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + Unit *trigger; int r; assert(p); @@ -472,7 +473,14 @@ static void path_enter_running(Path *p) { if (unit_stop_pending(UNIT(p))) return; - r = manager_add_job(UNIT(p)->manager, JOB_START, UNIT_TRIGGER(UNIT(p)), JOB_REPLACE, &error, NULL); + trigger = UNIT_TRIGGER(UNIT(p)); + if (!trigger) { + log_unit_error(UNIT(p), "Unit to trigger vanished."); + path_enter_dead(p, TIMER_FAILURE_RESOURCES); + return; + } + + r = manager_add_job(UNIT(p)->manager, JOB_START, trigger, JOB_REPLACE, &error, NULL); if (r < 0) goto fail; @@ -553,12 +561,16 @@ static void path_mkdir(Path *p) { static int path_start(Unit *u) { Path *p = PATH(u); + Unit *trigger; assert(p); assert(p->state == PATH_DEAD || p->state == PATH_FAILED); - if (UNIT_TRIGGER(u)->load_state != UNIT_LOADED) + trigger = UNIT_TRIGGER(u); + if (!trigger || trigger->load_state != UNIT_LOADED) { + log_unit_error(u, "Refusing to start, unit to trigger not loaded."); return -ENOENT; + } path_mkdir(p); |