summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2020-11-30 15:26:15 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-01 10:41:02 +0100
commitdc057df84c93274283cd228bc56733bc03a54195 (patch)
tree5d069f6ee6b8f2a48689c3f972cc480f1a29ed8f
parent450ba44b7e4393caf97d1069575bb932baec550b (diff)
downloadsystemd-247.1.tar.gz
scope: on unified, make sure to unwatch all PIDs once they've been moved to the cgroup scopev247.1
Commit 428a9f6f1d0396b9eacde2b38d667cbe3f15eb55 freed u->pids which is problematic since the references to this unit in m->watch_pids were no more removed when the unit was freed. This patch makes sure to clean all this refs up before freeing u->pids by calling unit_unwatch_all_pids(). (cherry picked from commit e9eec8b5d2c106c5dd51382a155e6045c7c17c1a)
-rw-r--r--src/core/scope.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/scope.c b/src/core/scope.c
index a372f8d726..5448d44bd7 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -377,10 +377,6 @@ static int scope_start(Unit *u) {
return r;
}
- /* Now u->pids have been moved into the scope cgroup, it's not needed
- * anymore. */
- u->pids = set_free(u->pids);
-
s->result = SCOPE_SUCCESS;
scope_set_state(s, SCOPE_RUNNING);
@@ -388,7 +384,13 @@ static int scope_start(Unit *u) {
/* Set the maximum runtime timeout. */
scope_arm_timer(s, usec_add(UNIT(s)->active_enter_timestamp.monotonic, s->runtime_max_usec));
- /* Start watching the PIDs currently in the scope */
+ /* On unified we use proper notifications hence we can unwatch the PIDs
+ * we just attached to the scope. This can also be done on legacy as
+ * we're going to update the list of the processes we watch with the
+ * PIDs currently in the scope anyway. */
+ unit_unwatch_all_pids(u);
+
+ /* Start watching the PIDs currently in the scope (legacy hierarchy only) */
(void) unit_enqueue_rewatch_pids(u);
return 1;
}