]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librados_test_stub: drop watches only after actually blocklisting
authorIlya Dryomov <idryomov@gmail.com>
Tue, 4 Apr 2023 15:21:16 +0000 (17:21 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 4 Apr 2023 15:58:36 +0000 (17:58 +0200)
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 <idryomov@gmail.com>
src/test/librados_test_stub/TestMemCluster.cc

index f829dd52c4ef421b6a295c6240ceb9e9d311b55a..f0995788b0f275c9d12db2913dedce4830ca271f 100644 (file)
@@ -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) {