From 46ce6decfe53839db22ffa9cad03795c9f3d6f2d Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 6 Jun 2024 07:16:14 -0400 Subject: [PATCH] LibProtocol: Exit fatally if the connection to RequestServer disappears The default implementation of die() causes the client process to simply exit cleanly. This prevents any tests from recognizing that something went wrong, as the process exits with a code of 0. With this patch, we still just exit when the connection dies, but with a fatal signal. In the future, we will want to launch a new RequestServer process and re-establish client connections. (cherry picked from commit d1ec32e28feee10c2c36f4cd0d496b8a95d375f8) --- Userland/Libraries/LibProtocol/RequestClient.cpp | 7 +++++++ Userland/Libraries/LibProtocol/RequestClient.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Userland/Libraries/LibProtocol/RequestClient.cpp b/Userland/Libraries/LibProtocol/RequestClient.cpp index 7f9f782403..835226b98f 100644 --- a/Userland/Libraries/LibProtocol/RequestClient.cpp +++ b/Userland/Libraries/LibProtocol/RequestClient.cpp @@ -14,6 +14,13 @@ RequestClient::RequestClient(NonnullOwnPtr socket) { } +void RequestClient::die() +{ + // FIXME: Gracefully handle this, or relaunch and reconnect to RequestServer. + warnln("\033[31;1mLost connection to RequestServer\033[0m"); + VERIFY_NOT_REACHED(); +} + void RequestClient::ensure_connection(URL::URL const& url, ::RequestServer::CacheLevel cache_level) { async_ensure_connection(url, cache_level); diff --git a/Userland/Libraries/LibProtocol/RequestClient.h b/Userland/Libraries/LibProtocol/RequestClient.h index 46c4a499e2..fbb1c79a3b 100644 --- a/Userland/Libraries/LibProtocol/RequestClient.h +++ b/Userland/Libraries/LibProtocol/RequestClient.h @@ -36,6 +36,8 @@ public: bool set_certificate(Badge, Request&, ByteString, ByteString); private: + virtual void die() override; + virtual void request_started(i32, IPC::File const&) override; virtual void request_progress(i32, Optional const&, u64) override; virtual void request_finished(i32, bool, u64) override;