|
|
2aacef |
From 9be28013e62ae471151fdc1f181e21cbd1e72dbd Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
2aacef |
Date: Fri, 10 Feb 2023 13:38:08 +0100
|
|
|
2aacef |
Subject: [PATCH] core: when isolating to a unit, also keep units running that
|
|
|
2aacef |
are triggered by units we keep running
|
|
|
2aacef |
|
|
|
2aacef |
Inspired by: #26364
|
|
|
2aacef |
|
|
|
2aacef |
(this might even "fix" #26364, but without debug logs it's hard to make
|
|
|
2aacef |
such claims)
|
|
|
2aacef |
|
|
|
2aacef |
Fixes: #23055
|
|
|
2aacef |
(cherry picked from commit 32d6707dd1692d41e12f5469dfdcbc10f14d6619)
|
|
|
2aacef |
|
|
|
2aacef |
Resolves: #1952378
|
|
|
2aacef |
---
|
|
|
2aacef |
src/core/transaction.c | 33 +++++++++++++++++++++++++++------
|
|
|
2aacef |
1 file changed, 27 insertions(+), 6 deletions(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/core/transaction.c b/src/core/transaction.c
|
|
|
2aacef |
index bafbb80b47..8ec853d58d 100644
|
|
|
2aacef |
--- a/src/core/transaction.c
|
|
|
2aacef |
+++ b/src/core/transaction.c
|
|
|
2aacef |
@@ -1092,6 +1092,20 @@ fail:
|
|
|
2aacef |
return r;
|
|
|
2aacef |
}
|
|
|
2aacef |
|
|
|
2aacef |
+static bool shall_stop_on_isolate(Transaction *tr, Unit *u) {
|
|
|
2aacef |
+ assert(tr);
|
|
|
2aacef |
+ assert(u);
|
|
|
2aacef |
+
|
|
|
2aacef |
+ if (u->ignore_on_isolate)
|
|
|
2aacef |
+ return false;
|
|
|
2aacef |
+
|
|
|
2aacef |
+ /* Is there already something listed for this? */
|
|
|
2aacef |
+ if (hashmap_get(tr->jobs, u))
|
|
|
2aacef |
+ return false;
|
|
|
2aacef |
+
|
|
|
2aacef |
+ return true;
|
|
|
2aacef |
+}
|
|
|
2aacef |
+
|
|
|
2aacef |
int transaction_add_isolate_jobs(Transaction *tr, Manager *m) {
|
|
|
2aacef |
Unit *u;
|
|
|
2aacef |
char *k;
|
|
|
2aacef |
@@ -1101,20 +1115,27 @@ int transaction_add_isolate_jobs(Transaction *tr, Manager *m) {
|
|
|
2aacef |
assert(m);
|
|
|
2aacef |
|
|
|
2aacef |
HASHMAP_FOREACH_KEY(u, k, m->units) {
|
|
|
2aacef |
+ Unit *o;
|
|
|
2aacef |
|
|
|
2aacef |
- /* ignore aliases */
|
|
|
2aacef |
+ /* Ignore aliases */
|
|
|
2aacef |
if (u->id != k)
|
|
|
2aacef |
continue;
|
|
|
2aacef |
|
|
|
2aacef |
- if (u->ignore_on_isolate)
|
|
|
2aacef |
+ /* No need to stop inactive units */
|
|
|
2aacef |
+ if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u)) && !u->job)
|
|
|
2aacef |
continue;
|
|
|
2aacef |
|
|
|
2aacef |
- /* No need to stop inactive jobs */
|
|
|
2aacef |
- if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u)) && !u->job)
|
|
|
2aacef |
+ if (!shall_stop_on_isolate(tr, u))
|
|
|
2aacef |
continue;
|
|
|
2aacef |
|
|
|
2aacef |
- /* Is there already something listed for this? */
|
|
|
2aacef |
- if (hashmap_get(tr->jobs, u))
|
|
|
2aacef |
+ /* Keep units that are triggered by units we want to keep around. */
|
|
|
2aacef |
+ bool keep = false;
|
|
|
2aacef |
+ UNIT_FOREACH_DEPENDENCY(o, u, UNIT_ATOM_TRIGGERED_BY)
|
|
|
2aacef |
+ if (!shall_stop_on_isolate(tr, o)) {
|
|
|
2aacef |
+ keep = true;
|
|
|
2aacef |
+ break;
|
|
|
2aacef |
+ }
|
|
|
2aacef |
+ if (keep)
|
|
|
2aacef |
continue;
|
|
|
2aacef |
|
|
|
2aacef |
r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, tr->anchor_job, true, false, false, false, NULL);
|