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

Unified Diff: content/zygote/zygote_linux.cc

Issue 24449002: NaCl: Clean up how FDs are passed to nacl_helper instances on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review - cleanup Created 7 years, 2 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 | « content/zygote/zygote_linux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/zygote/zygote_linux.cc
diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc
index 08f1ecbb5d29dd537b5394ab0c6a55ec9046d57a..cc509c1356c17bbd4235c1b264810618231069ed 100644
--- a/content/zygote/zygote_linux.cc
+++ b/content/zygote/zygote_linux.cc
@@ -41,6 +41,14 @@ namespace {
void SIGCHLDHandler(int signal) {
}
+int LookUpFd(const base::GlobalDescriptors::Mapping& fd_mapping, uint32_t key) {
+ for (size_t index = 0; index < fd_mapping.size(); ++index) {
+ if (fd_mapping[index].first == key)
+ return fd_mapping[index].second;
+ }
+ return -1;
+}
+
} // namespace
Zygote::Zygote(int sandbox_flags,
@@ -274,7 +282,7 @@ void Zygote::HandleGetTerminationStatus(int fd,
}
int Zygote::ForkWithRealPid(const std::string& process_type,
- std::vector<int>& fds,
+ const base::GlobalDescriptors::Mapping& fd_mapping,
const std::string& channel_switch,
std::string* uma_name,
int* uma_sample,
@@ -303,8 +311,15 @@ int Zygote::ForkWithRealPid(const std::string& process_type,
}
if (use_helper) {
- fds.push_back(dummy_fd);
- fds.push_back(pipe_fds[0]);
+ std::vector<int> fds;
+ int ipc_channel_fd = LookUpFd(fd_mapping, kPrimaryIPCChannel);
+ if (ipc_channel_fd < 0) {
+ DLOG(ERROR) << "Failed to find kPrimaryIPCChannel in FD mapping";
+ goto error;
+ }
+ fds.push_back(ipc_channel_fd); // kBrowserFDIndex
+ fds.push_back(dummy_fd); // kDummyFDIndex
+ fds.push_back(pipe_fds[0]); // kParentFDIndex
pid = helper_->Fork(fds);
} else {
pid = fork();
@@ -459,7 +474,7 @@ base::ProcessId Zygote::ReadArgsAndFork(const Pickle& pickle,
static_cast<uint32_t>(kSandboxIPCChannel), GetSandboxFD()));
// Returns twice, once per process.
- base::ProcessId child_pid = ForkWithRealPid(process_type, fds, channel_id,
+ base::ProcessId child_pid = ForkWithRealPid(process_type, mapping, channel_id,
uma_name, uma_sample,
uma_boundary_value);
if (!child_pid) {
« no previous file with comments | « content/zygote/zygote_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698