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

Unified Diff: chrome/nacl/nacl_helper_linux.cc

Issue 14238013: Set up NaClChromeMainArgs number_of_cores member so apps can size threadpools appropriately (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR fb Created 7 years, 8 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 | « no previous file | chrome/nacl/nacl_listener.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/nacl/nacl_helper_linux.cc
diff --git a/chrome/nacl/nacl_helper_linux.cc b/chrome/nacl/nacl_helper_linux.cc
index 53c2fb30118b87cebbbdedc64f3b1995da8ebbd2..a066db794aa43f3a5a314b5f7a1f41b59442df03 100644
--- a/chrome/nacl/nacl_helper_linux.cc
+++ b/chrome/nacl/nacl_helper_linux.cc
@@ -40,7 +40,8 @@ namespace {
// if (!child) {
// Note: this code doesn't attempt to support SELINUX or the SECCOMP sandbox.
void BecomeNaClLoader(const std::vector<int>& child_fds,
- size_t prereserved_sandbox_size) {
+ size_t prereserved_sandbox_size,
+ int number_of_cores) {
VLOG(1) << "NaCl loader: setting up IPC descriptor";
// don't need zygote FD any more
if (HANDLE_EINTR(close(kNaClZygoteDescriptor)) != 0)
@@ -51,6 +52,7 @@ void BecomeNaClLoader(const std::vector<int>& child_fds,
MessageLoopForIO main_message_loop;
NaClListener listener;
listener.set_prereserved_sandbox_size(prereserved_sandbox_size);
+ listener.set_number_of_cores(number_of_cores);
listener.Listen();
_exit(0);
}
@@ -58,7 +60,8 @@ void BecomeNaClLoader(const std::vector<int>& child_fds,
// Some of this code was lifted from
// content/browser/zygote_main_linux.cc:ForkWithRealPid()
void HandleForkRequest(const std::vector<int>& child_fds,
- size_t prereserved_sandbox_size) {
+ size_t prereserved_sandbox_size,
+ int number_of_cores) {
VLOG(1) << "nacl_helper: forking";
pid_t childpid = fork();
if (childpid < 0) {
@@ -96,7 +99,7 @@ void HandleForkRequest(const std::vector<int>& child_fds,
if (HANDLE_EINTR(close(child_fds[kNaClParentFDIndex])) != 0)
LOG(ERROR) << "close(child_fds[kNaClParentFDIndex]) failed";
if (validack) {
- BecomeNaClLoader(child_fds, prereserved_sandbox_size);
+ BecomeNaClLoader(child_fds, prereserved_sandbox_size, number_of_cores);
} else {
LOG(ERROR) << "Failed to synch with zygote";
}
@@ -236,6 +239,7 @@ int main(int argc, char* argv[]) {
#endif
std::vector<int> empty; // for SendMsg() calls
size_t prereserved_sandbox_size = CheckReservedAtZero();
+ int number_of_cores = sysconf(_SC_NPROCESSORS_ONLN);
CheckRDebug(argv[0]);
@@ -272,7 +276,7 @@ int main(int argc, char* argv[]) {
} else if (msglen == sizeof(kNaClForkRequest) - 1 &&
memcmp(buf, kNaClForkRequest, msglen) == 0) {
if (kNaClParentFDIndex + 1 == fds.size()) {
- HandleForkRequest(fds, prereserved_sandbox_size);
+ HandleForkRequest(fds, prereserved_sandbox_size, number_of_cores);
continue; // fork succeeded. Note: child does not return
} else {
LOG(ERROR) << "nacl_helper: unexpected number of fds, got "
« no previous file with comments | « no previous file | chrome/nacl/nacl_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698