mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
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.
This commit is contained in:
parent
8fd86fe6c9
commit
a446cea759
1 changed files with 8 additions and 0 deletions
|
@ -55,6 +55,7 @@ public:
|
||||||
{
|
{
|
||||||
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
|
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
|
||||||
m_notifier->on_ready_to_read = [this] {
|
m_notifier->on_ready_to_read = [this] {
|
||||||
|
NonnullRefPtr protect = *this;
|
||||||
drain_messages_from_peer();
|
drain_messages_from_peer();
|
||||||
handle_messages();
|
handle_messages();
|
||||||
};
|
};
|
||||||
|
@ -125,6 +126,13 @@ public:
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename RequestType, typename... Args>
|
||||||
|
OwnPtr<typename RequestType::ResponseType> send_sync_but_allow_failure(Args&&... args)
|
||||||
|
{
|
||||||
|
post_message(RequestType(forward<Args>(args)...));
|
||||||
|
return wait_for_specific_endpoint_message<typename RequestType::ResponseType, PeerEndpoint>();
|
||||||
|
}
|
||||||
|
|
||||||
virtual void may_have_become_unresponsive() { }
|
virtual void may_have_become_unresponsive() { }
|
||||||
virtual void did_become_responsive() { }
|
virtual void did_become_responsive() { }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue