Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1294)

Unified Diff: content/browser/zygote_host/zygote_host_impl_linux.cc

Issue 2744783002: Cleanup Linux OOM adjustment code. (Closed)
Patch Set: comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/chrome_main_delegate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/zygote_host/zygote_host_impl_linux.cc
diff --git a/content/browser/zygote_host/zygote_host_impl_linux.cc b/content/browser/zygote_host/zygote_host_impl_linux.cc
index e3338099a8e816cfe39c4ac15b348e1ca490ffe2..73ad92f8c2b67e8164af5c1832db7e27580878ab 100644
--- a/content/browser/zygote_host/zygote_host_impl_linux.cc
+++ b/content/browser/zygote_host/zygote_host_impl_linux.cc
@@ -244,38 +244,40 @@ void ZygoteHostImpl::AdjustRendererOOMScore(base::ProcessHandle pid,
base::FileEnumerator en(kSelinuxPath, false, base::FileEnumerator::FILES);
bool has_selinux_files = !en.Next().empty();
- selinux = access(kSelinuxPath.value().c_str(), X_OK) == 0 &&
- has_selinux_files;
+ selinux =
+ has_selinux_files && access(kSelinuxPath.value().c_str(), X_OK) == 0;
selinux_valid = true;
}
- if (use_suid_sandbox_for_adj_oom_score_ && !selinux) {
- // If heap profiling is running, these processes are not exiting, at least
- // on ChromeOS. The easiest thing to do is not launch them when profiling.
- // TODO(stevenjb): Investigate further and fix.
- if (base::allocator::IsHeapProfilerRunning())
- return;
-
- std::vector<std::string> adj_oom_score_cmdline;
- adj_oom_score_cmdline.push_back(sandbox_binary_);
- adj_oom_score_cmdline.push_back(sandbox::kAdjustOOMScoreSwitch);
- adj_oom_score_cmdline.push_back(base::Int64ToString(pid));
- adj_oom_score_cmdline.push_back(base::IntToString(score));
-
- base::Process sandbox_helper_process;
- base::LaunchOptions options;
-
- // sandbox_helper_process is a setuid binary.
- options.allow_new_privs = true;
-
- sandbox_helper_process =
- base::LaunchProcess(adj_oom_score_cmdline, options);
- if (sandbox_helper_process.IsValid())
- base::EnsureProcessGetsReaped(sandbox_helper_process.Pid());
- } else if (!use_suid_sandbox_for_adj_oom_score_) {
+ if (!use_suid_sandbox_for_adj_oom_score_) {
if (!base::AdjustOOMScore(pid, score))
PLOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid;
+ return;
}
+
+ if (selinux)
+ return;
+
+ // If heap profiling is running, these processes are not exiting, at least
+ // on ChromeOS. The easiest thing to do is not launch them when profiling.
+ // TODO(stevenjb): Investigate further and fix.
+ if (base::allocator::IsHeapProfilerRunning())
+ return;
+
+ std::vector<std::string> adj_oom_score_cmdline;
+ adj_oom_score_cmdline.push_back(sandbox_binary_);
+ adj_oom_score_cmdline.push_back(sandbox::kAdjustOOMScoreSwitch);
+ adj_oom_score_cmdline.push_back(base::Int64ToString(pid));
+ adj_oom_score_cmdline.push_back(base::IntToString(score));
+
+ // sandbox_helper_process is a setuid binary.
+ base::LaunchOptions options;
+ options.allow_new_privs = true;
+
+ base::Process sandbox_helper_process =
+ base::LaunchProcess(adj_oom_score_cmdline, options);
+ if (sandbox_helper_process.IsValid())
+ base::EnsureProcessGetsReaped(sandbox_helper_process.Pid());
}
#endif
« no previous file with comments | « chrome/app/chrome_main_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698