Skip to content

Commit

Permalink
rpc: optimize send error handling
Browse files Browse the repository at this point in the history
Remove the double dose of ssx::handle_shutdown_exceptions by inlining
the gate handling into a single place.

Remove the extra overhead of some lambdas and a couple of extra
continuations by handling unexpected errors and closing the gate in a
single continuation.

Signed-off-by: Tyler Rockwood <[email protected]>
  • Loading branch information
rockwotj committed Jul 26, 2023
1 parent 9670361 commit 8b5e350
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/v/rpc/transport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,23 @@ ss::future<> transport::do_dispatch_send() {
}

void transport::dispatch_send() {
ssx::spawn_with_gate(_dispatch_gate, [this]() mutable {
return ssx::ignore_shutdown_exceptions(do_dispatch_send())
.handle_exception([this](std::exception_ptr e) {
vlog(rpclog.info, "Error dispatching socket write:{}", e);
_probe->request_error();
fail_outstanding_futures();
});
});
if (!_dispatch_gate.try_enter()) {
return;
}
ssx::background = ssx::ignore_shutdown_exceptions(do_dispatch_send())
.then_wrapped([this](ss::future<> fut) {
if (fut.failed()) {
vlog(
rpclog.info,
"Error dispatching socket write:{}",
fut.get_exception());
_probe->request_error();
fail_outstanding_futures();
}
// Now that we've handled errors it's safe to
// release the gate.
_dispatch_gate.leave();
});
}

ss::future<> transport::do_reads() {
Expand Down

0 comments on commit 8b5e350

Please sign in to comment.