libroot: ensure that the launch_daemon doesn't wait for itself.
* The launch_daemon might indirectly call get_launch_daemon_port() which may cause a deadlock. Just fail in this case.
This commit is contained in:
@@ -16,9 +16,18 @@ static port_id sLaunchDaemonPort = -1;
|
||||
port_id
|
||||
BPrivate::get_launch_daemon_port()
|
||||
{
|
||||
if (sLaunchDaemonPort < 0)
|
||||
if (sLaunchDaemonPort < 0) {
|
||||
sLaunchDaemonPort = find_port(B_LAUNCH_DAEMON_PORT_NAME);
|
||||
|
||||
port_info info;
|
||||
if (get_port_info(sLaunchDaemonPort, &info) == B_OK
|
||||
&& info.team == find_thread(NULL)) {
|
||||
// Make sure that the launch_daemon doesn't wait on itself
|
||||
sLaunchDaemonPort = -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return sLaunchDaemonPort;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user