mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-03-01 20:37:58 +00:00
Use a bootstrap subset port for the inspector, tying the subset to the
lifetime of the task to be monitored, the invoking task. This allows the bootstrap server (in launchd) to automatically clean up the Mach server registration when the task being monitored exits, avoiding leaks of com.Breakpad.Inspector(pid) ports in "launchctl bslist". BUG=chromium:28547 TEST=Handler should still crash catches, but inspector ports should no longer show up in "launchctl bslist". They should show up under a subset port in "launchctl bstree" instead. "launchctl bstree" must be invoked as root. Review URL: http://breakpad.appspot.com/306001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@842 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
9dfe692010
commit
e7b75dbcc3
|
@ -32,8 +32,11 @@
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#define PRINT_MACH_RESULT(result_, message_) \
|
#define PRINT_MACH_RESULT(result_, message_) \
|
||||||
printf(message_"%s (%d)\n", mach_error_string(result_), result_ );
|
printf(message_"%s (%d)\n", mach_error_string(result_), result_ );
|
||||||
|
#define PRINT_BOOTSTRAP_RESULT(result_, message_) \
|
||||||
|
printf(message_"%s (%d)\n", bootstrap_strerror(result_), result_ );
|
||||||
#else
|
#else
|
||||||
#define PRINT_MACH_RESULT(result_, message_)
|
#define PRINT_MACH_RESULT(result_, message_)
|
||||||
|
#define PRINT_BOOTSTRAP_RESULT(result_, message_)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -67,15 +70,29 @@ kern_return_t OnDemandServer::Initialize(const char *server_command,
|
||||||
bool unregister_on_cleanup) {
|
bool unregister_on_cleanup) {
|
||||||
unregister_on_cleanup_ = unregister_on_cleanup;
|
unregister_on_cleanup_ = unregister_on_cleanup;
|
||||||
|
|
||||||
kern_return_t kr =
|
mach_port_t self_task = mach_task_self();
|
||||||
bootstrap_create_server(bootstrap_port,
|
|
||||||
const_cast<char*>(server_command),
|
|
||||||
geteuid(), // server uid
|
|
||||||
true,
|
|
||||||
&server_port_);
|
|
||||||
|
|
||||||
|
mach_port_t bootstrap_port;
|
||||||
|
kern_return_t kr = task_get_bootstrap_port(self_task, &bootstrap_port);
|
||||||
if (kr != KERN_SUCCESS) {
|
if (kr != KERN_SUCCESS) {
|
||||||
PRINT_MACH_RESULT(kr, "bootstrap_create_server() : ");
|
PRINT_MACH_RESULT(kr, "task_get_bootstrap_port(): ");
|
||||||
|
return kr;
|
||||||
|
}
|
||||||
|
|
||||||
|
mach_port_t bootstrap_subset_port;
|
||||||
|
kr = bootstrap_subset(bootstrap_port, self_task, &bootstrap_subset_port);
|
||||||
|
if (kr != KERN_SUCCESS) {
|
||||||
|
PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_subset(): ");
|
||||||
|
return kr;
|
||||||
|
}
|
||||||
|
|
||||||
|
kr = bootstrap_create_server(bootstrap_subset_port,
|
||||||
|
const_cast<char*>(server_command),
|
||||||
|
geteuid(), // server uid
|
||||||
|
true,
|
||||||
|
&server_port_);
|
||||||
|
if (kr != KERN_SUCCESS) {
|
||||||
|
PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_create_server(): ");
|
||||||
return kr;
|
return kr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,15 +103,14 @@ kern_return_t OnDemandServer::Initialize(const char *server_command,
|
||||||
kr = bootstrap_create_service(server_port_,
|
kr = bootstrap_create_service(server_port_,
|
||||||
const_cast<char*>(service_name),
|
const_cast<char*>(service_name),
|
||||||
&service_port_);
|
&service_port_);
|
||||||
|
|
||||||
if (kr != KERN_SUCCESS) {
|
if (kr != KERN_SUCCESS) {
|
||||||
PRINT_MACH_RESULT(kr, "bootstrap_create_service() : ");
|
PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_create_service(): ");
|
||||||
|
|
||||||
// perhaps the service has already been created - try to look it up
|
// perhaps the service has already been created - try to look it up
|
||||||
kr = bootstrap_look_up(bootstrap_port, (char*)service_name, &service_port_);
|
kr = bootstrap_look_up(bootstrap_port, (char*)service_name, &service_port_);
|
||||||
|
|
||||||
if (kr != KERN_SUCCESS) {
|
if (kr != KERN_SUCCESS) {
|
||||||
PRINT_MACH_RESULT(kr, "bootstrap_look_up() : ");
|
PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_look_up(): ");
|
||||||
Unregister(); // clean up server port
|
Unregister(); // clean up server port
|
||||||
return kr;
|
return kr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue