From 0e5fc0a29c4a98f781d4d4911b5f589f31c9f10e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 21 May 2025 04:38:07 +0900 Subject: [PATCH] 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. (cherry picked from commit 9b6aa9e443859f1eb69cfe37ca755ac4db31c475) --- src/core/transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/transaction.c b/src/core/transaction.c index eac97de71d3..fd1f58f498c 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -971,9 +971,9 @@ int transaction_add_job_and_dependencies( if (manager_unit_cache_should_retry_load(unit)) { assert(unit->load_state == UNIT_NOT_FOUND); unit->load_state = UNIT_STUB; - r = unit_load(unit); - if (r < 0 || unit->load_state == UNIT_STUB) - unit->load_state = UNIT_NOT_FOUND; + unit->load_error = 0; + (void) unit_load(unit); + assert(unit->load_state != UNIT_STUB); } r = bus_unit_validate_load_state(unit, e); -- 2.47.3