]> 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 58735/head
authorYuval Lifshitz <ylifshit@ibm.com>
Mon, 22 Jul 2024 16:10:55 +0000 (16:10 +0000)
committerYuval Lifshitz <ylifshit@ibm.com>
Tue, 23 Jul 2024 07:42:00 +0000 (07:42 +0000)
Fixes: https://tracker.ceph.com/issues/63786
Signed-off-by: Yuval Lifshitz <ylifshit@ibm.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) {