Skip to content

Commit

Permalink
LibCore: Don't try to unlink stale sockets in /tmp/rpc/
Browse files Browse the repository at this point in the history
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 SerenityOS#4876.
  • Loading branch information
awesomekling committed Jan 10, 2021
1 parent d38b991 commit f152b6f
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions Libraries/LibCore/EventLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f152b6f

Please sign in to comment.