From b5c4553a66e710ea53aa7045fce328c0681fda65 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 30 Jun 2022 16:02:26 +0300 Subject: [PATCH] storage_service: Sanitize stop_transport() It generates ignored future that can be avoided if using forwarding to shared_future<>'s promise Signed-off-by: Pavel Emelyanov --- service/storage_service.cc | 15 +++++---------- service/storage_service.hh | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/service/storage_service.cc b/service/storage_service.cc index c74257e70f..36313670a2 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -1282,9 +1282,10 @@ future<> endpoint_lifecycle_notifier::unregister_subscriber(endpoint_lifecycle_s future<> storage_service::stop_transport() { if (!_transport_stopped.has_value()) { - _transport_stopped.emplace(); + promise<> stopped; + _transport_stopped = stopped.get_future(); - (void) seastar::async([this] { + seastar::async([this] { slogger.info("Stop transport: starts"); slogger.debug("shutting down migration manager"); @@ -1301,18 +1302,12 @@ future<> storage_service::stop_transport() { _stream_manager.invoke_on_all(&streaming::stream_manager::shutdown).get(); slogger.info("Stop transport: shutdown stream_manager done"); - }).then_wrapped([this] (future<> f) { - if (f.failed()) { - _transport_stopped->set_exception(f.get_exception()); - } else { - _transport_stopped->set_value(); - } slogger.info("Stop transport: done"); - }); + }).forward_to(std::move(stopped)); } - return _transport_stopped->get_shared_future(); + return _transport_stopped.value(); } future<> storage_service::drain_on_shutdown() { diff --git a/service/storage_service.hh b/service/storage_service.hh index b9f23b4e5b..309538159e 100644 --- a/service/storage_service.hh +++ b/service/storage_service.hh @@ -734,7 +734,7 @@ public: private: promise<> _drain_finished; - std::optional> _transport_stopped; + std::optional> _transport_stopped; future<> do_drain(); /** * Seed data to the endpoints that will be responsible for it at the future