diff --git a/src/v/rpc/transport.cc b/src/v/rpc/transport.cc index 9b2d921c17e3f..65d9b1d5f86ea 100644 --- a/src/v/rpc/transport.cc +++ b/src/v/rpc/transport.cc @@ -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() {