diff options
author | Loic Dachary <loic@dachary.org> | 2013-08-27 13:58:33 +0200 |
---|---|---|
committer | Loic Dachary <loic@dachary.org> | 2013-08-27 13:59:57 +0200 |
commit | af5281e0f672554a322fef826d2229f563ae8577 (patch) | |
tree | c14c157a0a9d041f67c46944b745fc7a18517bdd | |
parent | a6fe776c3a04ddbc015ca104fa67ea8248bd0df9 (diff) | |
download | ceph-af5281e0f672554a322fef826d2229f563ae8577.tar.gz |
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 <loic@dachary.org>
-rw-r--r-- | src/test/common/test_sharedptr_registry.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/common/test_sharedptr_registry.cc b/src/test/common/test_sharedptr_registry.cc index aec2107c9e5..233412a3701 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) { |