From: Loic Dachary Date: Sun, 15 Dec 2013 13:31:27 +0000 (+0100) Subject: common: fix rare race condition in Throttle unit tests X-Git-Tag: v0.75~107^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F944%2Fhead;p=ceph.git common: fix rare race condition in Throttle unit tests The thread created to test Throttle race conditions updates a value ( throttle.get_current() ) 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/6679 fixes #6679 Signed-off-by: Loic Dachary --- diff --git a/src/test/common/Throttle.cc b/src/test/common/Throttle.cc index c07e242f9b2b..0964cbeffaf6 100644 --- a/src/test/common/Throttle.cc +++ b/src/test/common/Throttle.cc @@ -188,10 +188,8 @@ TEST_F(ThrottleTest, wait) { // throttle.wait(throttle_max * 100); usleep(delay); - ASSERT_EQ(throttle.get_current(), throttle_max / 2); - - t.join(); + ASSERT_EQ(throttle.get_current(), throttle_max / 2); if (!(waited = t.waited)) { delay *= 2;