diff options
Diffstat (limited to 'src/core/unit.c')
-rw-r--r-- | src/core/unit.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index 6dd075faa7..58c99d9e07 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1361,7 +1361,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { } /* Common implementation for multiple backends */ -int unit_load_fragment_and_dropin(Unit *u) { +int unit_load_fragment_and_dropin(Unit *u, bool fragment_required) { int r; assert(u); @@ -1371,8 +1371,12 @@ int unit_load_fragment_and_dropin(Unit *u) { if (r < 0) return r; - if (u->load_state == UNIT_STUB) - return -ENOENT; + if (u->load_state == UNIT_STUB) { + if (fragment_required) + return -ENOENT; + + u->load_state = UNIT_LOADED; + } /* Load drop-in directory data. If u is an alias, we might be reloading the * target unit needlessly. But we cannot be sure which drops-ins have already @@ -1381,27 +1385,6 @@ int unit_load_fragment_and_dropin(Unit *u) { return unit_load_dropin(unit_follow_merge(u)); } -/* Common implementation for multiple backends */ -int unit_load_fragment_and_dropin_optional(Unit *u) { - int r; - - assert(u); - - /* Same as unit_load_fragment_and_dropin(), but whether - * something can be loaded or not doesn't matter. */ - - /* Load a .service/.socket/.slice/… file */ - r = unit_load_fragment(u); - if (r < 0) - return r; - - if (u->load_state == UNIT_STUB) - u->load_state = UNIT_LOADED; - - /* Load drop-in directory data */ - return unit_load_dropin(unit_follow_merge(u)); -} - void unit_add_to_target_deps_queue(Unit *u) { Manager *m = u->manager; @@ -1559,16 +1542,11 @@ int unit_load(Unit *u) { u->fragment_mtime = now(CLOCK_REALTIME); } - if (UNIT_VTABLE(u)->load) { - r = UNIT_VTABLE(u)->load(u); - if (r < 0) - goto fail; - } - - if (u->load_state == UNIT_STUB) { - r = -ENOENT; + r = UNIT_VTABLE(u)->load(u); + if (r < 0) goto fail; - } + + assert(u->load_state != UNIT_STUB); if (u->load_state == UNIT_LOADED) { unit_add_to_target_deps_queue(u); |