Commit 66d1a60e authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

restore: don't race when closing cg yard

TASK_HELPERs are created with CLONE_FILES, so if we always close the cg yard
here, it will close it for the other helpers and cause problems. Instead, we
close it much later, in code only called by alive tasks, to ensure that there
is no conflict.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8c1a35b8
...@@ -1461,14 +1461,6 @@ static int restore_task_with_children(void *_arg) ...@@ -1461,14 +1461,6 @@ static int restore_task_with_children(void *_arg)
if (create_children_and_session()) if (create_children_and_session())
goto err_fini_mnt; goto err_fini_mnt;
/*
* This must be done after forking to allow child
* to get the cgroup fd so it can move into the
* correct /tasks file if it is in a different cgroup
* set than its parent
*/
close_service_fd(CGROUP_YARD);
if (restore_task_mnt_ns(current)) if (restore_task_mnt_ns(current))
goto err_fini_mnt; goto err_fini_mnt;
......
...@@ -949,6 +949,13 @@ int prepare_fds(struct pstree_item *me) ...@@ -949,6 +949,13 @@ int prepare_fds(struct pstree_item *me)
pr_info("Opening fdinfo-s\n"); pr_info("Opening fdinfo-s\n");
/*
* This must be done after forking to allow child
* to get the cgroup fd so it can move into the
* correct /tasks file if it is in a different cgroup
* set than its parent
*/
close_service_fd(CGROUP_YARD);
close_pid_proc(); /* flush any proc cached fds we may have */ close_pid_proc(); /* flush any proc cached fds we may have */
if (rsti(me)->fdt) { if (rsti(me)->fdt) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment