]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/cls_2pc_queue: fix multi-threaded access to non-atomic variables 62311/head
authorYuval Lifshitz <ylifshit@ibm.com>
Mon, 22 Jul 2024 16:10:55 +0000 (16:10 +0000)
committerAdam C. Emerson <aemerson@redhat.com>
Fri, 14 Mar 2025 19:20:07 +0000 (15:20 -0400)
Fixes: https://tracker.ceph.com/issues/63786
Signed-off-by: Yuval Lifshitz <ylifshit@ibm.com>
(cherry picked from commit 6f9f52033b0bb7b03ef569f12a970793ca65f0e8)

Fixes: https://tracker.ceph.com/issues/67143
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/test/cls_2pc_queue/test_cls_2pc_queue.cc

index 8384979249093a4e2ed9c32536205d579b501fa3..f0c71c7492e3239e58a4151ff945ddea4a975d0b 100644 (file)
@@ -803,7 +803,7 @@ TEST_F(TestCls2PCQueue, MultiProducer)
   cls_2pc_queue_init(op, queue_name, max_size);
   ASSERT_EQ(0, ioctx.operate(queue_name, &op));
 
-  auto producer_count = max_producer_count;
+  std::atomic<int>  producer_count = max_producer_count;
 
   std::vector<std::thread> producers(max_producer_count);
   for (auto& p : producers) {
@@ -925,9 +925,9 @@ TEST_F(TestCls2PCQueue, MultiProducerConsumer)
   cls_2pc_queue_init(op, queue_name, max_size);
   ASSERT_EQ(0, ioctx.operate(queue_name, &op));
 
-  auto producer_count = max_workers;
+  std::atomic<int> producer_count = max_workers;
 
-  auto retry_happened = false;
+  std::atomic<bool> retry_happened = false;
 
   std::vector<std::thread> producers(max_workers);
   for (auto& p : producers) {