diff --git a/src/v/http/client.cc b/src/v/http/client.cc index b8b442167c844..3cf055e19dc3f 100644 --- a/src/v/http/client.cc +++ b/src/v/http/client.cc @@ -172,6 +172,13 @@ ss::future client::get_connected( } ss::future<> client::stop() { + if (_stopped) { + // Prevent double call to stop() as constructs such as with_client() + // will unconditionally call stop(), while exception handlers in this + // file may also call stop() + co_return; + } + _stopped = true; co_await _connect_gate.close(); // Can safely stop base_transport co_return co_await base_transport::stop(); diff --git a/src/v/http/client.h b/src/v/http/client.h index d5595f5e5334a..4cbd053b9e42b 100644 --- a/src/v/http/client.h +++ b/src/v/http/client.h @@ -227,6 +227,7 @@ class client : protected net::base_transport { /// Throw exception if _as is aborted void check() const; + bool _stopped{false}; ss::gate _connect_gate; const ss::abort_source* _as; ss::shared_ptr _probe;