]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/transaction: drop redundant call of bus_unit_validate_load_state()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 May 2025 19:32:09 +0000 (04:32 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 25 Jun 2025 17:17:42 +0000 (18:17 +0100)
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 7ad2e660802be989d8ae8d0166c4fe1b7be0eb21)
(cherry picked from commit 915ffa770f3d65e28cf4ed8811140e9933eff242)

src/core/transaction.c

index aa9f16bbf09b24583afead35e9cda1e6d0a5f6e0..f541054d7232c5a9b6f9d50310b945c3a4a380e6 100644 (file)
@@ -963,7 +963,6 @@ int transaction_add_job_and_dependencies(
                 return sd_bus_error_setf(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->id);
 
         if (type != JOB_STOP) {
-                r = bus_unit_validate_load_state(unit, e);
                 /* The time-based cache allows new units to be started without daemon-reload, but if they are
                  * already referenced (because of dependencies or ordering) then we have to force a load of
                  * the fragment. As an optimization, check first if anything in the usual paths was modified
@@ -974,14 +973,15 @@ int transaction_add_job_and_dependencies(
                  *
                  * Given building up the transaction is a synchronous operation, attempt
                  * to load the unit immediately. */
-                if (r < 0 && manager_unit_cache_should_retry_load(unit)) {
-                        sd_bus_error_free(e);
+                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;
-                        r = bus_unit_validate_load_state(unit, e);
                 }
+
+                r = bus_unit_validate_load_state(unit, e);
                 if (r < 0)
                         return r;
         }