mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:28:10 +00:00
LibCore: Do not assert that we can start the RPC server
Now that the Shell uses Core::EventLoop, we can't afford to just crash if /tmp is unwritable.
This commit is contained in:
parent
53647e347f
commit
8afcf0d87a
3 changed files with 22 additions and 15 deletions
|
@ -233,20 +233,10 @@ EventLoop::EventLoop()
|
|||
ASSERT(rc == 0);
|
||||
s_event_loop_stack->append(this);
|
||||
|
||||
auto rpc_path = String::format("/tmp/rpc.%d", getpid());
|
||||
rc = unlink(rpc_path.characters());
|
||||
if (rc < 0 && errno != ENOENT) {
|
||||
perror("unlink");
|
||||
ASSERT_NOT_REACHED();
|
||||
if (!s_rpc_server) {
|
||||
if (!start_rpc_server())
|
||||
dbg() << "Core::EventLoop: Failed to start an RPC server";
|
||||
}
|
||||
s_rpc_server = LocalServer::construct();
|
||||
s_rpc_server->set_name("Core::EventLoop_RPC_server");
|
||||
bool listening = s_rpc_server->listen(rpc_path);
|
||||
ASSERT(listening);
|
||||
|
||||
s_rpc_server->on_ready_to_accept = [&] {
|
||||
RPCClient::construct(s_rpc_server->accept());
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef CEVENTLOOP_DEBUG
|
||||
|
@ -258,6 +248,22 @@ EventLoop::~EventLoop()
|
|||
{
|
||||
}
|
||||
|
||||
bool EventLoop::start_rpc_server()
|
||||
{
|
||||
auto rpc_path = String::format("/tmp/rpc.%d", getpid());
|
||||
int 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);
|
||||
}
|
||||
|
||||
EventLoop& EventLoop::main()
|
||||
{
|
||||
ASSERT(s_main_event_loop);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue