]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: move SharedPtrRegistry test after t.join 544/head
authorLoic Dachary <loic@dachary.org>
Tue, 27 Aug 2013 11:58:33 +0000 (13:58 +0200)
committerLoic Dachary <loic@dachary.org>
Tue, 27 Aug 2013 11:59:57 +0000 (13:59 +0200)
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 <loic@dachary.org>
src/test/common/test_sharedptr_registry.cc

index aec2107c9e5e76b6b537c933c9c9e06979ec5a57..233412a3701b6cb2a4239a19bd694e19f1eae6b0 100644 (file)
@@ -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) {