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

Unified Diff: content/browser/child_process_launcher.cc

Issue 10949027: Close leaking FDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated gypi file Created 8 years, 3 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
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index f7cf77224f44e04e098f4b121c9d4f2e73c5f00d..473f4e78b0cf86272d01f88c837ac9a9b35a5a84 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -166,28 +166,29 @@ class ChildProcessLauncher::Context
#elif defined(OS_ANDROID)
std::string process_type =
cmd_line->GetSwitchValueASCII(switches::kProcessType);
- base::GlobalDescriptors::Mapping files_to_register;
- files_to_register.push_back(std::pair<base::GlobalDescriptors::Key, int>(
- kPrimaryIPCChannel, ipcfd));
+ std::vector<content::FileDescriptorInfo> files_to_register;
+ files_to_register.push_back(
+ content::FileDescriptorInfo(kPrimaryIPCChannel,
+ base::FileDescriptor(ipcfd, false)));
+
content::GetContentClient()->browser()->
GetAdditionalMappedFilesForChildProcess(*cmd_line, &files_to_register);
- content::StartSandboxedProcess(cmd_line->argv(),
- ipcfd, files_to_register,
+ content::StartSandboxedProcess(cmd_line->argv(), files_to_register,
base::Bind(&ChildProcessLauncher::Context::OnSandboxedProcessStarted,
this_object, client_thread_id));
#elif defined(OS_POSIX)
base::ProcessHandle handle = base::kNullProcessHandle;
- // We need to close the client end of the IPC channel
- // to reliably detect child termination.
- file_util::ScopedFD ipcfd_closer(&ipcfd);
-
std::string process_type =
cmd_line->GetSwitchValueASCII(switches::kProcessType);
- base::GlobalDescriptors::Mapping files_to_register;
- files_to_register.push_back(std::pair<base::GlobalDescriptors::Key, int>(
- kPrimaryIPCChannel, ipcfd));
+ std::vector<content::FileDescriptorInfo> files_to_register;
+ // We need to close the client end of the IPC channel to reliably detect
+ // child termination, so we set autoclose to true.
+ base::FileDescriptor ipc_file_descriptor(ipcfd, true);
+ files_to_register.push_back(
+ content::FileDescriptorInfo(kPrimaryIPCChannel, ipc_file_descriptor));
+
#if !defined(OS_MACOSX)
content::GetContentClient()->browser()->
GetAdditionalMappedFilesForChildProcess(*cmd_line, &files_to_register);
@@ -201,12 +202,12 @@ class ChildProcessLauncher::Context
{
// Convert FD mapping to FileHandleMappingVector
base::FileHandleMappingVector fds_to_map;
- for (size_t i = 0; i < files_to_register.size(); ++i) {
- const base::GlobalDescriptors::KeyFDPair& id_file =
- files_to_register[i];
+ for (std::vector<content::FileDescriptorInfo>::const_iterator
+ i = files_to_register.begin(); i != files_to_register.end(); ++i) {
+ const content::FileDescriptorInfo& fd_info = *i;
fds_to_map.push_back(std::make_pair(
- id_file.second,
- id_file.first + base::GlobalDescriptors::kBaseDescriptor));
+ fd_info.fd.fd,
+ fd_info.id + base::GlobalDescriptors::kBaseDescriptor));
}
#if !defined(OS_MACOSX)
« no previous file with comments | « content/browser/android/sandboxed_process_launcher.cc ('k') | content/browser/zygote_host/zygote_host_impl_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698