mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 02:08:12 +03: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
Notes:
sideshowbarker
2024-07-19 06:00:35 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/8afcf0d87a5 Pull-request: https://github.com/SerenityOS/serenity/pull/2430 Reviewed-by: https://github.com/alimpfard
@ -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);
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
static void wake();
|
||||
|
||||
private:
|
||||
bool start_rpc_server();
|
||||
void wait_for_event(WaitMode);
|
||||
Optional<struct timeval> get_next_timer_expiration();
|
||||
|
||||
|
@ -123,13 +123,13 @@ bool LocalServer::listen(const String& address)
|
||||
rc = ::bind(m_fd, (const sockaddr*)&un, sizeof(un));
|
||||
if (rc < 0) {
|
||||
perror("bind");
|
||||
ASSERT_NOT_REACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = ::listen(m_fd, 5);
|
||||
if (rc < 0) {
|
||||
perror("listen");
|
||||
ASSERT_NOT_REACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_listening = true;
|
||||
|
Loading…
Reference in New Issue
Block a user