From a35942e09a7cf3d4cb5dad8b91b0795797c74bbb Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 25 Aug 2024 16:19:38 +0300 Subject: [PATCH] repair: row_level: coroutinize repair_meta::get_full_row_hashes_sink_op() Extra care is needed for exception handling. --- repair/row_level.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/repair/row_level.cc b/repair/row_level.cc index bae9401b20..5e2a76167d 100644 --- a/repair/row_level.cc +++ b/repair/row_level.cc @@ -1530,13 +1530,17 @@ private: } future<> get_full_row_hashes_sink_op(rpc::sink& sink) { - return sink(repair_stream_cmd::get_full_row_hashes).then([&sink] { - return sink.flush(); - }).handle_exception([&sink] (std::exception_ptr ep) { - return sink.close().then([ep = std::move(ep)] () mutable { - return make_exception_future<>(std::move(ep)); - }); - }); + std::exception_ptr ep; + try { + co_await sink(repair_stream_cmd::get_full_row_hashes); + co_await sink.flush(); + } catch (...) { + ep = std::current_exception(); + } + if (ep) { + co_await sink.close(); + std::rethrow_exception(ep); + } } public: