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.
This commit is contained in:
Timothy Flynn 2022-11-08 09:30:25 -05:00 committed by Tim Flynn
parent 3994a79718
commit a4fc7dbf6d
Notes: sideshowbarker 2024-07-17 10:31:19 +09:00
2 changed files with 4 additions and 1 deletions

View file

@ -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;
}

View file

@ -24,6 +24,7 @@ public:
ErrorOr<NonnullOwnPtr<Stream::LocalSocket>> accept();
Function<void(NonnullOwnPtr<Stream::LocalSocket>)> on_accept;
Function<void(Error)> on_accept_error;
private:
explicit LocalServer(Object* parent = nullptr);