]> git.ipfire.org Git - thirdparty/systemd.git/commit
core/transaction: do not override unit load state when unit_load() failed
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 May 2025 19:38:07 +0000 (04:38 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 May 2025 20:37:34 +0000 (05:37 +0900)
commit9b6aa9e443859f1eb69cfe37ca755ac4db31c475
treeac1ecec3eae4c6404a1eb5f55a4d9451a751b6f0
parent7ad2e660802be989d8ae8d0166c4fe1b7be0eb21
core/transaction: do not override unit load state when unit_load() failed

When unit_load() failed for some reasons, previously we overrided the
load state with UNIT_NOT_FOUND, but we did not update the
Unit.fragment_not_found_timestamp_hash. So, the unit may be loaded
multiple times when the unit is in a dependency list of another unit,
as manager_unit_cache_should_retry_load() will be true again even on
next call.
Let's not override the unit state set by unit_load().

Note, after unit_load(), the unit state should not be UNIT_STUB.
Let's also add the assertion about that.

This change is important when combined with the next commit, as with the
next commit we will restart the FOREACH_UNIT_DEPENDENCY() loop if an unit
is reloaded, hence overriding load state with UNIT_NOT_FOUND may cause
infinit loop.
src/core/transaction.c