From: Casey Bodley Date: Fri, 1 Aug 2025 15:42:56 +0000 (-0400) Subject: rgw/asio: add scope guard warn_about_blocking_in_scope X-Git-Tag: testing/wip-vshankar-testing-20251027.053005-debug~24^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bd20e7bd1de70ba0ee3e11a1bcddfb3e11328b06;p=ceph-ci.git rgw/asio: add scope guard warn_about_blocking_in_scope Signed-off-by: Casey Bodley --- 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; + } +};