From f152b6f7ed60b02f603b8a3de89ed45074a9fa63 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 10 Jan 2021 11:21:35 +0100 Subject: [PATCH] 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. --- Libraries/LibCore/EventLoop.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Libraries/LibCore/EventLoop.cpp b/Libraries/LibCore/EventLoop.cpp index 31aa8fb118..9fe4a2039e 100644 --- a/Libraries/LibCore/EventLoop.cpp +++ b/Libraries/LibCore/EventLoop.cpp @@ -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()