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

Unified Diff: content/browser/zygote_host/zygote_host_impl_linux.cc

Issue 10949027: Close leaking FDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed last comments and synced. 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
« no previous file with comments | « content/browser/zygote_host/zygote_host_impl_linux.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6ef54874282fb8d0e882d01b08297705504cb1b3..7d084ac84946ef4fbfe3633b8ef9553e7d51b79a 100644
--- a/content/browser/zygote_host/zygote_host_impl_linux.cc
+++ b/content/browser/zygote_host/zygote_host_impl_linux.cc
@@ -16,6 +16,7 @@
#include "base/file_util.h"
#include "base/linux_util.h"
#include "base/logging.h"
+#include "base/memory/linked_ptr.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
@@ -238,7 +239,7 @@ ssize_t ZygoteHostImpl::ReadReply(void* buf, size_t buf_len) {
pid_t ZygoteHostImpl::ForkRequest(
const std::vector<std::string>& argv,
- const base::GlobalDescriptors::Mapping& mapping,
+ const std::vector<content::FileDescriptorInfo>& mapping,
const std::string& process_type) {
DCHECK(init_);
Pickle pickle;
@@ -253,10 +254,20 @@ pid_t ZygoteHostImpl::ForkRequest(
pickle.WriteInt(mapping.size());
std::vector<int> fds;
- for (base::GlobalDescriptors::Mapping::const_iterator
+ // Scoped pointers cannot be stored in containers, so we have to use a
+ // linked_ptr.
+ std::vector<linked_ptr<file_util::ScopedFD> > autodelete_fds;
+ for (std::vector<content::FileDescriptorInfo>::const_iterator
i = mapping.begin(); i != mapping.end(); ++i) {
- pickle.WriteUInt32(i->first);
- fds.push_back(i->second);
+ 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 habe been passed
+ // to the other process.
+ linked_ptr<file_util::ScopedFD> ptr(
+ new file_util::ScopedFD(&(fds.back())));
+ autodelete_fds.push_back(ptr);
+ }
}
pid_t pid;
« no previous file with comments | « content/browser/zygote_host/zygote_host_impl_linux.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698