From: Zbigniew Jędrzejewski-Szmek Date: Sat, 22 Jul 2017 12:39:49 +0000 (-0400) Subject: Revert "core: don't load dropin data multiple times for the same unit (#5139)" X-Git-Tag: v235~300^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e4ea9cc34fa032a47c253ddd94ac6c7afda663e;p=thirdparty%2Fsystemd.git Revert "core: don't load dropin data multiple times for the same unit (#5139)" This reverts commit 2d058a87ffb2d31a50422a8aebd119bbb4427244. When we add another name to a unit (by following an alias), we need to reload all drop-ins. This is necessary to load any additional dropins found in the dirs created from the alias name. Fixes #6334. --- diff --git a/src/core/unit.c b/src/core/unit.c index b28eeb2262f..9d913e8c644 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1098,7 +1098,6 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { /* Common implementation for multiple backends */ int unit_load_fragment_and_dropin(Unit *u) { - Unit *t; int r; assert(u); @@ -1111,18 +1110,15 @@ int unit_load_fragment_and_dropin(Unit *u) { if (u->load_state == UNIT_STUB) return -ENOENT; - /* If the unit is an alias and the final unit has already been - * loaded, there's no point in reloading the dropins one more time. */ - t = unit_follow_merge(u); - if (t != u && t->load_state != UNIT_STUB) - return 0; - - return unit_load_dropin(t); + /* 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 + * been loaded and which not, at least without doing complicated book-keeping, + * so let's always reread all drop-ins. */ + return unit_load_dropin(unit_follow_merge(u)); } /* Common implementation for multiple backends */ int unit_load_fragment_and_dropin_optional(Unit *u) { - Unit *t; int r; assert(u); @@ -1138,13 +1134,8 @@ int unit_load_fragment_and_dropin_optional(Unit *u) { if (u->load_state == UNIT_STUB) u->load_state = UNIT_LOADED; - /* If the unit is an alias and the final unit has already been - * loaded, there's no point in reloading the dropins one more time. */ - t = unit_follow_merge(u); - if (t != u && t->load_state != UNIT_STUB) - return 0; - - return unit_load_dropin(t); + /* Load drop-in directory data */ + return unit_load_dropin(unit_follow_merge(u)); } int unit_add_default_target_dependency(Unit *u, Unit *target) {