File 5003-core-when-isolating-keep-triggered-units-only-if-the.patch of Package systemd

From 08bc4a518aa15d81976896b00d89d847d1a6c040 Mon Sep 17 00:00:00 2001
From: Franck Bui <fbui@suse.com>
Date: Wed, 26 Nov 2025 11:38:34 +0100
Subject: [PATCH 1/1] core: when isolating, keep triggered units only if their
 triggers are actually not stopped

Follow-up for 32d6707dd1692d41e12f5469dfdcbc10f14d6619.
---
 src/core/transaction.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/core/transaction.c b/src/core/transaction.c
index 536f9d78c3..54139283de 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -1205,18 +1205,20 @@ int transaction_add_isolate_jobs(Transaction *tr, Manager *m) {
                         continue;
 
                 /* Keep units that are triggered by units we want to keep around. */
-                bool keep = false;
-                UNIT_FOREACH_DEPENDENCY(o, u, UNIT_ATOM_TRIGGERED_BY)
-                        if (!shall_stop_on_isolate(tr, o)) {
-                                keep = true;
-                                break;
-                        }
-                if (keep)
-                        continue;
+                UNIT_FOREACH_DEPENDENCY(o, u, UNIT_ATOM_TRIGGERED_BY) {
+                        if (o->ignore_on_isolate)
+                                goto keep_unit;
+
+                        /* Keep triggered units only if their triggers are actually not stopped. */
+                        Job *j = hashmap_get(tr->jobs, o);
+                        if (j && j->type != JOB_STOP)
+                                goto keep_unit;
+                }
 
                 r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, tr->anchor_job, TRANSACTION_MATTERS, &e);
                 if (r < 0)
                         log_unit_warning_errno(u, r, "Cannot add isolate job, ignoring: %s", bus_error_message(&e, r));
+keep_unit:
         }
 
         return 0;
-- 
2.51.0

openSUSE Build Service is sponsored by