summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-18 13:11:28 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-30 14:01:46 +0200
commite8630e695232bdfcd16b55f3faafb4329c961104 (patch)
treedce17c3db55aa13c5f64ed6f8a415e6eea3db7fd /src/core/unit.c
parent7d1e91d1a9504ab1bc03894038f90a8e87a4e982 (diff)
downloadsystemd-e8630e695232bdfcd16b55f3faafb4329c961104.tar.gz
systemd-e8630e695232bdfcd16b55f3faafb4329c961104.tar.bz2
systemd-e8630e695232bdfcd16b55f3faafb4329c961104.zip
pid1: use a cache for all unit aliases
This reworks how we load units from disk. Instead of chasing symlinks every time we are asked to load a unit by name, we slurp all symlinks from disk and build two hashmaps: 1. from unit name to either alias target, or fragment on disk (if an alias, we put just the target name in the hashmap, if a fragment we put an absolute path, so we can distinguish both). 2. from a unit name to all aliases Reading all this data can be pretty costly (40 ms) on my machine, so we keep it around for reuse. The advantage is that we can reliably know what all the aliases of a given unit are. This means we can reliably load dropins under all names. This fixes #11972.
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index fa89bd4a4d..7561f1e1a1 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -949,6 +949,9 @@ int unit_merge_by_name(Unit *u, const char *name) {
Unit *other;
int r;
+ /* Either add name to u, or if a unit with name already exists, merge it with u.
+ * If name is a template, do the same for name@instance, where instance is u's instance. */
+
assert(u);
assert(name);