From 0dfe87d3b6ed52cee6f6660b42af42a8dd7708bb Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Thu, 30 Mar 2023 18:22:24 +0200 Subject: [PATCH] test/librados_test_stub: raise a watch error on blocklisting Simulate getting MWatchNotify CEPH_WATCH_EVENT_DISCONNECT message after the client is blocklisted. Signed-off-by: Ilya Dryomov --- src/test/librados_test_stub/TestWatchNotify.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/librados_test_stub/TestWatchNotify.cc b/src/test/librados_test_stub/TestWatchNotify.cc index 48aaf64ef14fb..93875182c9b40 100644 --- a/src/test/librados_test_stub/TestWatchNotify.cc +++ b/src/test/librados_test_stub/TestWatchNotify.cc @@ -402,7 +402,16 @@ void TestWatchNotify::blocklist(uint32_t nonce) { auto &watcher = file_it->second; for (auto w_it = watcher->watch_handles.begin(); w_it != watcher->watch_handles.end();) { - if (w_it->second.nonce == nonce) { + auto& watch_handle = w_it->second; + if (watch_handle.nonce == nonce) { + auto handle = watch_handle.handle; + auto watch_ctx2 = watch_handle.watch_ctx2; + if (watch_ctx2 != nullptr) { + auto ctx = new LambdaContext([handle, watch_ctx2](int) { + watch_ctx2->handle_error(handle, -ENOTCONN); + }); + watch_handle.rados_client->get_aio_finisher()->queue(ctx); + } w_it = watcher->watch_handles.erase(w_it); } else { ++w_it;