Skip to content

Commit f4d1cf1

Browse files
yuwatabluca
authored andcommitted
core/transaction: drop redundant call of bus_unit_validate_load_state()
The function manager_unit_cache_should_retry_load() reutrns true only when the unit state is UNIT_NOT_FOUND. Hence, it is not necessary to call bus_unit_validate_load_state() before checking manager_unit_cache_should_retry_load(). (cherry picked from commit 7ad2e66) (cherry picked from commit 915ffa770f3d65e28cf4ed8811140e9933eff242) (cherry picked from commit cca17f069bdc72bcb1a9d9d9e3b8d4b2064037e9) (cherry picked from commit eae4a19)
1 parent 6f2d929 commit f4d1cf1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/core/transaction.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,6 @@ int transaction_add_job_and_dependencies(
971971
return sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->id);
972972

973973
if (type != JOB_STOP) {
974-
r = bus_unit_validate_load_state(unit, e);
975974
/* The time-based cache allows to start new units without daemon-reload, but if they are
976975
* already referenced (because of dependencies or ordering) then we have to force a load of
977976
* the fragment. As an optimization, check first if anything in the usual paths was modified
@@ -982,14 +981,15 @@ int transaction_add_job_and_dependencies(
982981
*
983982
* Given building up the transaction is a synchronous operation, attempt
984983
* to load the unit immediately. */
985-
if (r < 0 && manager_unit_cache_should_retry_load(unit)) {
986-
sd_bus_error_free(e);
984+
if (manager_unit_cache_should_retry_load(unit)) {
985+
assert(unit->load_state == UNIT_NOT_FOUND);
987986
unit->load_state = UNIT_STUB;
988987
r = unit_load(unit);
989988
if (r < 0 || unit->load_state == UNIT_STUB)
990989
unit->load_state = UNIT_NOT_FOUND;
991-
r = bus_unit_validate_load_state(unit, e);
992990
}
991+
992+
r = bus_unit_validate_load_state(unit, e);
993993
if (r < 0)
994994
return r;
995995
}

0 commit comments

Comments
 (0)