From a14498eff645e9e154e4d1a3cc436453b8401d89 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Tue, 4 Apr 2023 17:21:16 +0200 Subject: [PATCH] test/librados_test_stub: drop watches only after actually blocklisting Eliminate a race where a client is able to submit an operation after WatchCtx2::handle_error() is invoked on its watch due to blocklisting. Signed-off-by: Ilya Dryomov --- src/test/librados_test_stub/TestMemCluster.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/librados_test_stub/TestMemCluster.cc b/src/test/librados_test_stub/TestMemCluster.cc index f829dd52c4ef4..f0995788b0f27 100644 --- a/src/test/librados_test_stub/TestMemCluster.cc +++ b/src/test/librados_test_stub/TestMemCluster.cc @@ -174,10 +174,13 @@ bool TestMemCluster::is_blocklisted(uint32_t nonce) const { } void TestMemCluster::blocklist(uint32_t nonce) { - m_watch_notify.blocklist(nonce); + { + std::lock_guard locker{m_lock}; + m_blocklist.insert(nonce); + } - std::lock_guard locker{m_lock}; - m_blocklist.insert(nonce); + // after blocklisting the client, disconnect and drop its watches + m_watch_notify.blocklist(nonce); } void TestMemCluster::transaction_start(const ObjectLocator& locator) { -- 2.39.5