LibCore: Don't try to unlink stale sockets in /tmp/rpc/

This was very obviously racy and would only succeed if we already own
the socket anyway. (And if we do, we can bind to it without unlinking!)

Work towards #4876.
This commit is contained in:
Andreas Kling 2021-01-10 11:21:35 +01:00
parent d38b9916c9
commit f152b6f7ed
Notes: sideshowbarker 2024-07-18 23:58:06 +09:00

View file

@ -314,18 +314,12 @@ EventLoop::~EventLoop()
bool EventLoop::start_rpc_server()
{
auto rpc_path = String::formatted("/tmp/rpc/{}", getpid());
auto rc = unlink(rpc_path.characters());
if (rc < 0 && errno != ENOENT) {
perror("unlink");
return false;
}
s_rpc_server = LocalServer::construct();
s_rpc_server->set_name("Core::EventLoop_RPC_server");
s_rpc_server->on_ready_to_accept = [&] {
RPCClient::construct(s_rpc_server->accept());
};
return s_rpc_server->listen(rpc_path);
return s_rpc_server->listen(String::formatted("/tmp/rpc/{}", getpid()));
}
EventLoop& EventLoop::main()