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

Unified Diff: chrome/app/chrome_main_mac.mm

Issue 8059041: Use bootstrap subset ports to overcome Mach port mapping leaks and -10810 errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | « chrome/app/chrome_main_mac.h ('k') | chrome/renderer/chrome_render_process_observer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/chrome_main_mac.mm
===================================================================
--- chrome/app/chrome_main_mac.mm (revision 103028)
+++ chrome/app/chrome_main_mac.mm (working copy)
@@ -5,6 +5,8 @@
#include "chrome/app/chrome_main_mac.h"
#import <Cocoa/Cocoa.h>
+#include <mach/mach.h>
+#include <servers/bootstrap.h>
#include <string>
@@ -43,3 +45,45 @@
NSBundle* base_bundle = chrome::OuterAppBundle();
base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]);
}
+
+void SwitchToMachBootstrapSubsetPort() {
+ // Testing tip: use launchctl bstree (as root) to make sure that the
+ // subset port is created properly and that new mappings wind up added to
+ // the subset port.
+
+#ifndef NDEBUG
+ static bool once_only = false;
+ DCHECK(!once_only);
+ once_only = true;
+#endif
+
+ mach_port_t self_task = mach_task_self();
+
+ mach_port_t original_bootstrap_port;
+ kern_return_t kr = task_get_bootstrap_port(self_task,
+ &original_bootstrap_port);
+ if (kr != KERN_SUCCESS) {
+ LOG(ERROR) << "task_get_bootstrap_port: " << kr << " "
+ << mach_error_string(kr);
+ return;
+ }
+
+ mach_port_t bootstrap_subset_port;
+ kr = bootstrap_subset(original_bootstrap_port,
+ self_task,
+ &bootstrap_subset_port);
+ if (kr != BOOTSTRAP_SUCCESS) {
+ LOG(ERROR) << "bootstrap_subset: " << kr << " " << bootstrap_strerror(kr);
+ return;
+ }
+
+ kr = task_set_bootstrap_port(self_task, bootstrap_subset_port);
+ if (kr != KERN_SUCCESS) {
+ LOG(ERROR) << "task_set_bootstrap_port: " << kr << " "
+ << mach_error_string(kr);
+ return;
+ }
+
+ // Users of the bootstrap port often access it through this global variable.
+ bootstrap_port = bootstrap_subset_port;
+}
« no previous file with comments | « chrome/app/chrome_main_mac.h ('k') | chrome/renderer/chrome_render_process_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698