Commit beebf12b by Serge Hallyn Committed by Stéphane Graber

[PATCH cgmanager chown: don't do a gratuitous fork

userns_exec_1() clones a new task to manipulate. We don't need to fork before calling that. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 7a435f9a
...@@ -246,7 +246,6 @@ static int chown_cgroup_wrapper(void *data) ...@@ -246,7 +246,6 @@ static int chown_cgroup_wrapper(void *data)
static bool chown_cgroup(const char *controller, const char *cgroup_path, static bool chown_cgroup(const char *controller, const char *cgroup_path,
struct lxc_conf *conf) struct lxc_conf *conf)
{ {
pid_t pid;
struct chown_data data; struct chown_data data;
data.controller = controller; data.controller = controller;
data.cgroup_path = cgroup_path; data.cgroup_path = cgroup_path;
...@@ -257,20 +256,11 @@ static bool chown_cgroup(const char *controller, const char *cgroup_path, ...@@ -257,20 +256,11 @@ static bool chown_cgroup(const char *controller, const char *cgroup_path,
return true; return true;
} }
if ((pid = fork()) < 0) { if (userns_exec_1(conf, chown_cgroup_wrapper, &data) < 0) {
SYSERROR("fork"); ERROR("Error requesting cgroup chown in new namespace");
return false; return false;
} }
if (pid > 0) { return true;
if (wait_for_pid(pid)) {
ERROR("Error chowning cgroup");
return false;
}
return true;
}
if (userns_exec_1(conf, chown_cgroup_wrapper, &data) < 0)
exit(1);
exit(0);
} }
struct cgm_data { struct cgm_data {
......
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