From af5281e0f672554a322fef826d2229f563ae8577 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 27 Aug 2013 13:58:33 +0200 Subject: [PATCH] common: move SharedPtrRegistry test after t.join The thread created to test SharedPtrRegistry race conditions updates a value ( ptr ) that is tested by the main gtest thread but is not protected by a lock. Instead of adding a lock, the main thread tests the value after pthread_join() on the child thread. http://tracker.ceph.com/issues/6130 fixes #6130 Signed-off-by: Loic Dachary --- src/test/common/test_sharedptr_registry.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/common/test_sharedptr_registry.cc b/src/test/common/test_sharedptr_registry.cc index aec2107c9e5e..233412a3701b 100644 --- a/src/test/common/test_sharedptr_registry.cc +++ b/src/test/common/test_sharedptr_registry.cc @@ -137,8 +137,8 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) { EXPECT_TRUE(registry.lookup_or_create(key + 12345)); registry.remove(key); ASSERT_TRUE(wait_for(registry, 0)); - EXPECT_TRUE(t.ptr); t.join(); + EXPECT_TRUE(t.ptr); } { unsigned int key = 2; @@ -163,9 +163,9 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) { } registry.remove(key); ASSERT_TRUE(wait_for(registry, 0)); + t.join(); EXPECT_TRUE(t.ptr); EXPECT_EQ(value, *t.ptr); - t.join(); } } @@ -200,8 +200,8 @@ TEST_F(SharedPtrRegistry_all, wait_lookup) { EXPECT_FALSE(registry.lookup(key + 12345)); registry.remove(key); ASSERT_TRUE(wait_for(registry, 0)); - EXPECT_FALSE(t.ptr); t.join(); + EXPECT_FALSE(t.ptr); } TEST_F(SharedPtrRegistry_all, get_next) { -- 2.47.3