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>
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;
}
registry.remove(key);
ASSERT_TRUE(wait_for(registry, 0));
+ t.join();
EXPECT_TRUE(t.ptr);
EXPECT_EQ(value, *t.ptr);
- t.join();
}
}
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) {