From acde644322201518c6445ea1f40575df89d61dbd Mon Sep 17 00:00:00 2001 From: Michal Maslanka Date: Mon, 1 Aug 2022 11:12:58 +0200 Subject: [PATCH] r/consensus: coroutinized raft::stop() method Signed-off-by: Michal Maslanka --- src/v/raft/consensus.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/v/raft/consensus.cc b/src/v/raft/consensus.cc index 0e4abe85f1c8..2c97020b6c41 100644 --- a/src/v/raft/consensus.cc +++ b/src/v/raft/consensus.cc @@ -240,18 +240,16 @@ ss::future<> consensus::stop() { for (auto& idx : _fstats) { idx.second.follower_state_change.broken(); } - return _event_manager.stop() - .then([this] { return _append_requests_buffer.stop(); }) - .then([this] { return _batcher.stop(); }) - .then([this] { return _bg.close(); }) - .then([this] { - // close writer if we have to - if (likely(!_snapshot_writer)) { - return ss::now(); - } - return _snapshot_writer->close().then( - [this] { _snapshot_writer.reset(); }); - }); + co_await _event_manager.stop(); + co_await _append_requests_buffer.stop(); + co_await _batcher.stop(); + co_await _bg.close(); + + // close writer if we have to + if (unlikely(_snapshot_writer)) { + co_await _snapshot_writer->close(); + _snapshot_writer.reset(); + } } consensus::success_reply consensus::update_follower_index(