From a446cea75909a9571191f1c45e7bb4ba91b7df23 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 20 Feb 2021 11:07:29 +0100 Subject: [PATCH] LibIPC: Add Connection::send_sync_but_allow_failure() Instead of asserting that the peer responds successfully, this API allows for the peer to die/crash/whatever happens on the other side while handling a synchronous request. This will be useful when using process separation to parse untrusted data from the web. --- Userland/Libraries/LibIPC/Connection.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Userland/Libraries/LibIPC/Connection.h b/Userland/Libraries/LibIPC/Connection.h index 899eaa6412..c6b281aa18 100644 --- a/Userland/Libraries/LibIPC/Connection.h +++ b/Userland/Libraries/LibIPC/Connection.h @@ -55,6 +55,7 @@ public: { m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); }); m_notifier->on_ready_to_read = [this] { + NonnullRefPtr protect = *this; drain_messages_from_peer(); handle_messages(); }; @@ -125,6 +126,13 @@ public: return response; } + template + OwnPtr send_sync_but_allow_failure(Args&&... args) + { + post_message(RequestType(forward(args)...)); + return wait_for_specific_endpoint_message(); + } + virtual void may_have_become_unresponsive() { } virtual void did_become_responsive() { }