From bd20e7bd1de70ba0ee3e11a1bcddfb3e11328b06 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 1 Aug 2025 11:42:56 -0400 Subject: [PATCH] rgw/asio: add scope guard warn_about_blocking_in_scope Signed-off-by: Casey Bodley --- src/rgw/rgw_asio_thread.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rgw/rgw_asio_thread.h b/src/rgw/rgw_asio_thread.h index 788f8ee295d..68fad088f25 100644 --- a/src/rgw/rgw_asio_thread.h +++ b/src/rgw/rgw_asio_thread.h @@ -15,6 +15,8 @@ #pragma once +#include + class DoutPrefixProvider; /// indicates whether the current thread is in boost::asio::io_context::run(), @@ -24,3 +26,14 @@ extern thread_local bool is_asio_thread; /// call when an operation will block the calling thread due to an empty /// optional_yield. a warning is logged when is_asio_thread is true void maybe_warn_about_blocking(const DoutPrefixProvider* dpp); + +/// enables warnings while in scope. these scopes must not be nested +struct warn_about_blocking_in_scope { + warn_about_blocking_in_scope() { + assert(!is_asio_thread); + is_asio_thread = true; + } + ~warn_about_blocking_in_scope() { + is_asio_thread = false; + } +}; -- 2.39.5