From a4fc7dbf6df8dbd94c1742b155d9e0bd92726dd6 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 8 Nov 2022 09:30:25 -0500 Subject: [PATCH] LibCore: Add support for LocalServer to propogate accept() errors We still log the error (perhaps in the future, we will only want to log the error if there is no handler). But this allows callers to actually handle errors to e.g. unblock waiters. --- Userland/Libraries/LibCore/LocalServer.cpp | 4 +++- Userland/Libraries/LibCore/LocalServer.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCore/LocalServer.cpp b/Userland/Libraries/LibCore/LocalServer.cpp index d246e2c8db1..d4ed0cac75b 100644 --- a/Userland/Libraries/LibCore/LocalServer.cpp +++ b/Userland/Libraries/LibCore/LocalServer.cpp @@ -54,7 +54,9 @@ void LocalServer::setup_notifier() if (on_accept) { auto maybe_client_socket = accept(); if (maybe_client_socket.is_error()) { - dbgln("LocalServer::on_ready_to_read: Error accepting a connection: {} (FIXME: should propagate!)", maybe_client_socket.error()); + dbgln("LocalServer::on_ready_to_read: Error accepting a connection: {}", maybe_client_socket.error()); + if (on_accept_error) + on_accept_error(maybe_client_socket.release_error()); return; } diff --git a/Userland/Libraries/LibCore/LocalServer.h b/Userland/Libraries/LibCore/LocalServer.h index 8554ec59373..c4854a70694 100644 --- a/Userland/Libraries/LibCore/LocalServer.h +++ b/Userland/Libraries/LibCore/LocalServer.h @@ -24,6 +24,7 @@ public: ErrorOr> accept(); Function)> on_accept; + Function on_accept_error; private: explicit LocalServer(Object* parent = nullptr);