]> git.ipfire.org Git - thirdparty/systemd.git/commit
pid1: use a cache for all unit aliases
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 18 Jul 2019 11:11:28 +0000 (13:11 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 30 Jul 2019 12:01:46 +0000 (14:01 +0200)
commite8630e695232bdfcd16b55f3faafb4329c961104
treedce17c3db55aa13c5f64ed6f8a415e6eea3db7fd
parent7d1e91d1a9504ab1bc03894038f90a8e87a4e982
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.
src/core/load-fragment.c
src/core/manager.c
src/core/manager.h
src/core/unit.c
src/shared/unit-file.c
src/shared/unit-file.h
src/systemctl/systemctl.c
src/test/test-unit-file.c
test/TEST-15-DROPIN/test-dropin.sh