]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/asio: add scope guard warn_about_blocking_in_scope
authorCasey Bodley <cbodley@redhat.com>
Fri, 1 Aug 2025 15:42:56 +0000 (11:42 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 21 Oct 2025 13:08:04 +0000 (09:08 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_asio_thread.h

index 788f8ee295d76b1cb205a7c89da5a3952073a7e5..68fad088f25b8a07aa9cdc2d481cd1e1e415c694 100644 (file)
@@ -15,6 +15,8 @@
 
 #pragma once
 
+#include <assert.h>
+
 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;
+  }
+};