Chromium Code Reviews| Index: content/zygote/zygote_linux.cc |
| diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc |
| index 08f1ecbb5d29dd537b5394ab0c6a55ec9046d57a..c3e09bda042f2a95228449108acc5b2ac37d3949 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,6 +311,13 @@ int Zygote::ForkWithRealPid(const std::string& process_type, |
| } |
| if (use_helper) { |
| + 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); |
|
jln (very slow on Chromium)
2013/09/30 19:15:39
I don't understand why this works. The size of fds
Mark Seaborn
2013/10/01 22:32:54
I'm not increasing the number of FDs that is sent
jln (very slow on Chromium)
2013/10/01 22:51:46
Ohh yeah of course, sorry I missed that.
Mark Seaborn
2013/10/07 15:23:13
I've made that change. Please take a look.
|
| fds.push_back(dummy_fd); |
| fds.push_back(pipe_fds[0]); |
| pid = helper_->Fork(fds); |
| @@ -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) { |