From 9670361db3d5c8a514a1984512300d17fa1122ec Mon Sep 17 00:00:00 2001 From: Tyler Rockwood Date: Wed, 26 Jul 2023 11:46:46 -0500 Subject: [PATCH] ssx: Optimize the implementation of handle_shutdown_exceptions Create less of a continuation chain by handling all the exceptions in a single coroutine. Signed-off-by: Tyler Rockwood --- src/v/ssx/future-util.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/v/ssx/future-util.h b/src/v/ssx/future-util.h index 6bee1620fb36..df5f7fc65bcd 100644 --- a/src/v/ssx/future-util.h +++ b/src/v/ssx/future-util.h @@ -268,12 +268,14 @@ inline constexpr detail::background_t background; /// \brief Create a new future, handling common shutdown exception types. inline seastar::future<> ignore_shutdown_exceptions(seastar::future<> fut) noexcept { - return std::move(fut) - .handle_exception_type([](const seastar::abort_requested_exception&) {}) - .handle_exception_type([](const seastar::gate_closed_exception&) {}) - .handle_exception_type([](const seastar::broken_semaphore&) {}) - .handle_exception_type([](const seastar::broken_promise&) {}) - .handle_exception_type([](const seastar::broken_condition_variable&) {}); + try { + co_await std::move(fut); + } catch (const seastar::abort_requested_exception&) { + } catch (const seastar::gate_closed_exception&) { + } catch (const seastar::broken_semaphore&) { + } catch (const seastar::broken_promise&) { + } catch (const seastar::broken_condition_variable&) { + } } /// \brief Check if the exception is a commonly ignored shutdown exception.