core: only activate transaction that contain useful jobs

If no real jobs were added to the transaction, do not activate it.
The JOB_NOP anchor does not perform any useful work and activating
such transaction only wastes resources.

Fixes #9751
This commit is contained in:
Michal Sekletar
2026-01-15 12:53:50 +01:00
committed by Mike Yuan
parent 311fddcd8d
commit bcbf80c43d
+5
View File
@@ -2278,6 +2278,11 @@ int manager_propagate_reload(Manager *m, Unit *unit, JobMode mode, sd_bus_error
tr->anchor_job,
mode == JOB_IGNORE_DEPENDENCIES ? TRANSACTION_IGNORE_ORDER : 0);
/* Only activate the transaction if it contains jobs other than NOP anchor.
* Short-circuiting here avoids unnecessary processing, such as emitting D-Bus signals. */
if (hashmap_size(tr->jobs) <= 1)
return 0;
r = transaction_activate(tr, m, mode, NULL, e);
if (r < 0)
return r;