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 <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2022-06-30 16:02:26 +03:00
parent 4fd289a78c
commit b5c4553a66
2 changed files with 6 additions and 11 deletions

View File

@@ -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() {

View File

@@ -734,7 +734,7 @@ public:
private:
promise<> _drain_finished;
std::optional<shared_promise<>> _transport_stopped;
std::optional<shared_future<>> _transport_stopped;
future<> do_drain();
/**
* Seed data to the endpoints that will be responsible for it at the future