teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0016-Revert-core-don-t-load-dropin-data-multiple-times-fo.patch

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