Skip to content

Commit 3a169fc

Browse files
yuwatabluca
authored andcommitted
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 9b6aa9e) (cherry picked from commit 0e5fc0a29c4a98f781d4d4911b5f589f31c9f10e) (cherry picked from commit 7dfa163cecb3e79daf35ad9858d0e9b725cb2234) (cherry picked from commit 87aea85)
1 parent f4d1cf1 commit 3a169fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/transaction.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,9 @@ int transaction_add_job_and_dependencies(
984984
if (manager_unit_cache_should_retry_load(unit)) {
985985
assert(unit->load_state == UNIT_NOT_FOUND);
986986
unit->load_state = UNIT_STUB;
987-
r = unit_load(unit);
988-
if (r < 0 || unit->load_state == UNIT_STUB)
989-
unit->load_state = UNIT_NOT_FOUND;
987+
unit->load_error = 0;
988+
(void) unit_load(unit);
989+
assert(unit->load_state != UNIT_STUB);
990990
}
991991

992992
r = bus_unit_validate_load_state(unit, e);

0 commit comments

Comments
 (0)