27bd1bd
From 29d9cfc097586ac79911a5f5035c45b1971a5b1f Mon Sep 17 00:00:00 2001
27bd1bd
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
27bd1bd
Date: Sat, 22 Jul 2017 08:39:49 -0400
27bd1bd
Subject: [PATCH] Revert "core: don't load dropin data multiple times for the
27bd1bd
 same unit (#5139)"
27bd1bd
27bd1bd
This reverts commit 2d058a87ffb2d31a50422a8aebd119bbb4427244.
27bd1bd
27bd1bd
When we add another name to a unit (by following an alias), we need to
27bd1bd
reload all drop-ins. This is necessary to load any additional dropins
27bd1bd
found in the dirs created from the alias name.
27bd1bd
27bd1bd
Fixes #6334.
27bd1bd
27bd1bd
(cherry picked from commit 9e4ea9cc34fa032a47c253ddd94ac6c7afda663e)
27bd1bd
---
27bd1bd
 src/core/unit.c | 23 +++++++----------------
27bd1bd
 1 file changed, 7 insertions(+), 16 deletions(-)
27bd1bd
27bd1bd
diff --git a/src/core/unit.c b/src/core/unit.c
27bd1bd
index b28eeb2262..9d913e8c64 100644
27bd1bd
--- a/src/core/unit.c
27bd1bd
+++ b/src/core/unit.c
27bd1bd
@@ -1098,7 +1098,6 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
27bd1bd
 
27bd1bd
 /* Common implementation for multiple backends */
27bd1bd
 int unit_load_fragment_and_dropin(Unit *u) {
27bd1bd
-        Unit *t;
27bd1bd
         int r;
27bd1bd
 
27bd1bd
         assert(u);
27bd1bd
@@ -1111,18 +1110,15 @@ int unit_load_fragment_and_dropin(Unit *u) {
27bd1bd
         if (u->load_state == UNIT_STUB)
27bd1bd
                 return -ENOENT;
27bd1bd
 
27bd1bd
-        /* If the unit is an alias and the final unit has already been
27bd1bd
-         * loaded, there's no point in reloading the dropins one more time. */
27bd1bd
-        t = unit_follow_merge(u);
27bd1bd
-        if (t != u && t->load_state != UNIT_STUB)
27bd1bd
-                return 0;
27bd1bd
-
27bd1bd
-        return unit_load_dropin(t);
27bd1bd
+        /* Load drop-in directory data. If u is an alias, we might be reloading the
27bd1bd
+         * target unit needlessly. But we cannot be sure which drops-ins have already
27bd1bd
+         * been loaded and which not, at least without doing complicated book-keeping,
27bd1bd
+         * so let's always reread all drop-ins. */
27bd1bd
+        return unit_load_dropin(unit_follow_merge(u));
27bd1bd
 }
27bd1bd
 
27bd1bd
 /* Common implementation for multiple backends */
27bd1bd
 int unit_load_fragment_and_dropin_optional(Unit *u) {
27bd1bd
-        Unit *t;
27bd1bd
         int r;
27bd1bd
 
27bd1bd
         assert(u);
27bd1bd
@@ -1138,13 +1134,8 @@ int unit_load_fragment_and_dropin_optional(Unit *u) {
27bd1bd
         if (u->load_state == UNIT_STUB)
27bd1bd
                 u->load_state = UNIT_LOADED;
27bd1bd
 
27bd1bd
-        /* If the unit is an alias and the final unit has already been
27bd1bd
-         * loaded, there's no point in reloading the dropins one more time. */
27bd1bd
-        t = unit_follow_merge(u);
27bd1bd
-        if (t != u && t->load_state != UNIT_STUB)
27bd1bd
-                return 0;
27bd1bd
-
27bd1bd
-        return unit_load_dropin(t);
27bd1bd
+        /* Load drop-in directory data */
27bd1bd
+        return unit_load_dropin(unit_follow_merge(u));
27bd1bd
 }
27bd1bd
 
27bd1bd
 int unit_add_default_target_dependency(Unit *u, Unit *target) {