mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibCore: Don't create an RPC server when built for lagom
There's no reason to have this, and it will most likely fail anyway (since there's likely no /tmp/rpc).
This commit is contained in:
parent
096d2d5071
commit
b2b3ccb12d
Notes:
sideshowbarker
2024-07-18 23:53:26 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/b2b3ccb12d6 Pull-request: https://github.com/SerenityOS/serenity/pull/4922
1 changed files with 14 additions and 2 deletions
|
@ -149,15 +149,16 @@ public:
|
|||
: m_socket(move(socket))
|
||||
, m_client_id(s_id_allocator->allocate())
|
||||
{
|
||||
#ifdef __serenity__
|
||||
s_rpc_clients.set(m_client_id, this);
|
||||
add_child(*m_socket);
|
||||
m_socket->on_ready_to_read = [this] {
|
||||
u32 length;
|
||||
int nread = m_socket->read((u8*)&length, sizeof(length));
|
||||
if (nread == 0) {
|
||||
#ifdef EVENTLOOP_DEBUG
|
||||
# ifdef EVENTLOOP_DEBUG
|
||||
dbgln("RPC client disconnected");
|
||||
#endif
|
||||
# endif
|
||||
shutdown();
|
||||
return;
|
||||
}
|
||||
|
@ -173,6 +174,9 @@ public:
|
|||
|
||||
handle_request(request_json.value().as_object());
|
||||
};
|
||||
#else
|
||||
warnln("RPC Client constructed outside serenity, this is very likely a bug!");
|
||||
#endif
|
||||
}
|
||||
virtual ~RPCClient() override
|
||||
{
|
||||
|
@ -297,10 +301,12 @@ EventLoop::EventLoop()
|
|||
ASSERT(rc == 0);
|
||||
s_event_loop_stack->append(this);
|
||||
|
||||
#ifdef __serenity__
|
||||
if (!s_rpc_server) {
|
||||
if (!start_rpc_server())
|
||||
dbgln("Core::EventLoop: Failed to start an RPC server");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef EVENTLOOP_DEBUG
|
||||
|
@ -314,12 +320,16 @@ EventLoop::~EventLoop()
|
|||
|
||||
bool EventLoop::start_rpc_server()
|
||||
{
|
||||
#ifdef __serenity__
|
||||
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(String::formatted("/tmp/rpc/{}", getpid()));
|
||||
#else
|
||||
ASSERT_NOT_REACHED();
|
||||
#endif
|
||||
}
|
||||
|
||||
EventLoop& EventLoop::main()
|
||||
|
@ -597,8 +607,10 @@ void EventLoop::notify_forked(ForkEvent event)
|
|||
info->next_signal_id = 0;
|
||||
}
|
||||
s_pid = 0;
|
||||
#ifdef __serenity__
|
||||
s_rpc_server = nullptr;
|
||||
s_rpc_clients.clear();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue