fix mem clean in finishFromParent
This commit is contained in:
parent
5b82f51b8a
commit
26869e8956
22
cgroup.cc
22
cgroup.cc
@ -79,17 +79,17 @@ static bool initNsFromParentMem(nsjconf_t* nsjconf, pid_t pid) {
|
|||||||
RETURN_ON_FAILURE(writeToCgroup(
|
RETURN_ON_FAILURE(writeToCgroup(
|
||||||
mem_cgroup_path + "/memory.oom_control", "0", "memory cgroup oom control"));
|
mem_cgroup_path + "/memory.oom_control", "0", "memory cgroup oom control"));
|
||||||
|
|
||||||
if (nsjconf->cgroup_mem_max > (size_t)0) {
|
if (nsjconf->cgroup_mem_max > (size_t)0) {
|
||||||
std::string mem_max_str = std::to_string(nsjconf->cgroup_mem_max);
|
std::string mem_max_str = std::to_string(nsjconf->cgroup_mem_max);
|
||||||
RETURN_ON_FAILURE(writeToCgroup(
|
RETURN_ON_FAILURE(writeToCgroup(mem_cgroup_path + "/memory.limit_in_bytes",
|
||||||
mem_cgroup_path + "/memory.limit_in_bytes", mem_max_str, "memory cgroup max limit"));
|
mem_max_str, "memory cgroup max limit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsjconf->cgroup_mem_memsw_max > (size_t)0) {
|
if (nsjconf->cgroup_mem_memsw_max > (size_t)0) {
|
||||||
std::string mem_memsw_max_str = std::to_string(nsjconf->cgroup_mem_memsw_max);
|
std::string mem_memsw_max_str = std::to_string(nsjconf->cgroup_mem_memsw_max);
|
||||||
RETURN_ON_FAILURE(writeToCgroup(
|
RETURN_ON_FAILURE(writeToCgroup(mem_cgroup_path + "/memory.memsw.limit_in_bytes",
|
||||||
mem_cgroup_path + "/memory.memsw.limit_in_bytes", mem_memsw_max_str, "memory+Swap cgroup max limit"));
|
mem_memsw_max_str, "memory+Swap cgroup max limit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return addPidToTaskList(mem_cgroup_path, pid);
|
return addPidToTaskList(mem_cgroup_path, pid);
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ static void removeCgroup(const std::string& cgroup_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void finishFromParent(nsjconf_t* nsjconf, pid_t pid) {
|
void finishFromParent(nsjconf_t* nsjconf, pid_t pid) {
|
||||||
if (nsjconf->cgroup_mem_max != (size_t)0) {
|
if (nsjconf->cgroup_mem_max != (size_t)0 || nsjconf->cgroup_mem_memsw_max != (size_t)0) {
|
||||||
std::string mem_cgroup_path = nsjconf->cgroup_mem_mount + '/' +
|
std::string mem_cgroup_path = nsjconf->cgroup_mem_mount + '/' +
|
||||||
nsjconf->cgroup_mem_parent + "/NSJAIL." +
|
nsjconf->cgroup_mem_parent + "/NSJAIL." +
|
||||||
std::to_string(pid);
|
std::to_string(pid);
|
||||||
|
Loading…
Reference in New Issue
Block a user