From fff7c34ce740f88b995a18a26749214807a8ef38 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 Sep 2023 16:24:23 +0200 Subject: [PATCH 1/2] scope: add trailing comma to array initialization --- src/core/scope.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/scope.c b/src/core/scope.c index eb3ffba084..d8860a6da1 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -29,7 +29,7 @@ static const UnitActiveState state_translation_table[_SCOPE_STATE_MAX] = { [SCOPE_ABANDONED] = UNIT_ACTIVE, [SCOPE_STOP_SIGTERM] = UNIT_DEACTIVATING, [SCOPE_STOP_SIGKILL] = UNIT_DEACTIVATING, - [SCOPE_FAILED] = UNIT_FAILED + [SCOPE_FAILED] = UNIT_FAILED, }; static int scope_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata); From 05d1630e7022a424db894e31044c950e5995235d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 Sep 2023 16:24:32 +0200 Subject: [PATCH 2/2] scope: only stop watching processes when we go down Let's not stop watching processes on every scope state change. This corrects behaviour when a scope is being enqueued and hasn't started yet, but has processes associated to it already. previously, if we'd doa full PID 1 reload we'd stop watching those pids. With this change we'll continue watching them in that case, and only stop watching them when the scope unit really shuts down after first being up. --- src/core/scope.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/scope.c b/src/core/scope.c index d8860a6da1..1bcd4ed84f 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -119,7 +119,7 @@ static void scope_set_state(Scope *s, ScopeState state) { if (!IN_SET(state, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL, SCOPE_START_CHOWN, SCOPE_RUNNING)) s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source); - if (IN_SET(state, SCOPE_DEAD, SCOPE_FAILED)) { + if (!IN_SET(old_state, SCOPE_DEAD, SCOPE_FAILED) && IN_SET(state, SCOPE_DEAD, SCOPE_FAILED)) { unit_unwatch_all_pids(UNIT(s)); unit_dequeue_rewatch_pids(UNIT(s)); }