]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: only activate transaction that contain useful jobs
authorMichal Sekletar <msekleta@redhat.com>
Fri, 9 Jan 2026 16:18:41 +0000 (17:18 +0100)
committerMike Yuan <me@yhndnzj.com>
Thu, 15 Jan 2026 11:53:50 +0000 (12:53 +0100)
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

src/core/manager.c

index 490b209d998d7072e09f878c2b181e3e590d4f2d..508b9fc9345600aef789dd4076d6887f20105db4 100644 (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;