Chromium Code Reviews| 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 0ead4ce1c33d9005adfed3a95abc88a823ec7b46..b30262a026ba9711eed9ae914808a3780468a271 100644 |
| --- a/content/browser/zygote_host/zygote_host_impl_linux.cc |
| +++ b/content/browser/zygote_host/zygote_host_impl_linux.cc |
| @@ -287,10 +287,9 @@ ssize_t ZygoteHostImpl::ReadReply(void* buf, size_t buf_len) { |
| return HANDLE_EINTR(read(control_fd_, buf, buf_len)); |
| } |
| -pid_t ZygoteHostImpl::ForkRequest( |
| - const std::vector<std::string>& argv, |
| - const std::vector<FileDescriptorInfo>& mapping, |
| - const std::string& process_type) { |
| +pid_t ZygoteHostImpl::ForkRequest(const std::vector<std::string>& argv, |
| + scoped_ptr<FileDescriptorInfo> mapping, |
| + const std::string& process_type) { |
| DCHECK(init_); |
| Pickle pickle; |
| @@ -309,26 +308,17 @@ pid_t ZygoteHostImpl::ForkRequest( |
| // Fork requests contain one file descriptor for the PID oracle, and one |
| // more for each file descriptor mapping for the child process. |
| - const size_t num_fds_to_send = 1 + mapping.size(); |
| + const size_t num_fds_to_send = 1 + mapping->size(); |
| pickle.WriteInt(num_fds_to_send); |
| std::vector<int> fds; |
| - ScopedVector<base::ScopedFD> autoclose_fds; |
| // First FD to send is peer_sock. |
| fds.push_back(peer_sock.get()); |
| - autoclose_fds.push_back(new base::ScopedFD(peer_sock.Pass())); |
| - |
| // The rest come from mapping. |
| - for (std::vector<FileDescriptorInfo>::const_iterator |
| - i = mapping.begin(); i != mapping.end(); ++i) { |
| - pickle.WriteUInt32(i->id); |
| - fds.push_back(i->fd.fd); |
| - if (i->fd.auto_close) { |
| - // Auto-close means we need to close the FDs after they have been passed |
| - // to the other process. |
| - autoclose_fds.push_back(new base::ScopedFD(i->fd.fd)); |
| - } |
| + for (size_t i = 0; i < mapping->size(); ++i) { |
| + pickle.WriteUInt32(mapping->GetIDAt(i)); |
| + fds.push_back(mapping->GetFDAt(i)); |
| } |
| // Sanity check that we've populated |fds| correctly. |
| @@ -339,7 +329,8 @@ pid_t ZygoteHostImpl::ForkRequest( |
| base::AutoLock lock(control_lock_); |
| if (!SendMessage(pickle, &fds)) |
| return base::kNullProcessHandle; |
| - autoclose_fds.clear(); |
| + peer_sock.reset(); |
| + mapping.reset(); |
|
jln (very slow on Chromium)
2014/09/22 17:54:15
I find this slightly worse. Having one autoclose_f
mdempsky
2014/09/22 18:30:51
Agreed, though it's overall fewer lines of code, s
Hajime Morrita
2014/09/22 22:59:26
Let me have some addition to FileDescriptorInfo to
|
| { |
| char buf[sizeof(kZygoteChildPingMessage) + 1]; |