diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2021-01-12 17:38:52 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-12 16:21:34 +0100 |
commit | b2b3ccb12d69d3e9a2a902777f942b9da5218236 (patch) | |
tree | 40c938b2ca9790f13a4f44944e6f30ddbf34335d /Userland/Libraries | |
parent | 096d2d507174689758f865dddf87b1f1ec19389e (diff) | |
download | serenity-b2b3ccb12d69d3e9a2a902777f942b9da5218236.zip |
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).
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibCore/EventLoop.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp index c13cc986ea..daa464dfbe 100644 --- a/Userland/Libraries/LibCore/EventLoop.cpp +++ b/Userland/Libraries/LibCore/EventLoop.cpp @@ -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; } |