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:
Axel Dörfler
2015-07-22 20:41:09 +02:00
parent 1f374c8b2a
commit ef462ab57f
+10 -1
View File
@@ -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;
}