]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: delay adding target dependencies until all units are loaded and aliases resolve...
authorMichal Sekletar <msekletar@users.noreply.github.com>
Fri, 23 Mar 2018 14:28:06 +0000 (15:28 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Mar 2018 14:28:06 +0000 (15:28 +0100)
commit19496554e23ea4861ce780430052dcf86a2ffcba
treef4833cafbb3b523179a088595f797d817694b6ad
parent959071cac27c0f59df11a204522b887ae2bec02a
core: delay adding target dependencies until all units are loaded and aliases resolved (#8381)

Currently we add target dependencies while we are loading units. This
can create ordering loops even if configuration doesn't contain any
loop. Take for example following configuration,

$ systemctl get-default
multi-user.target

$ cat /etc/systemd/system/test.service
[Unit]
After=default.target

[Service]
ExecStart=/bin/true

[Install]
WantedBy=multi-user.target

If we encounter such unit file early during manager start-up (e.g. load
queue is dispatched while enumerating devices due to SYSTEMD_WANTS in
udev rules) we would add stub unit default.target and we order it Before
test.service. At the same time we add implicit Before to
multi-user.target. Later we merge two units and we create ordering cycle
in the process.

To fix the issue we will now never add any target dependencies until we
loaded all the unit files and resolved all the aliases.
src/core/manager.c
src/core/manager.h
src/core/unit.c
src/core/unit.h