From ff8008993927acf780e51ca7e0e636c002dad8f0 Mon Sep 17 00:00:00 2001 From: Gudmundur Adalsteinsson Date: Sat, 18 Apr 2020 12:44:59 +0000 Subject: [PATCH] Problem: Spinning on atomics can cause hangs Solution: Add a sleep in the loop. Some versions of valgrind may hang when spinning on atomic variables. --- unittests/unittest_poller.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unittests/unittest_poller.cpp b/unittests/unittest_poller.cpp index a7a7457a..0d150d82 100644 --- a/unittests/unittest_poller.cpp +++ b/unittests/unittest_poller.cpp @@ -103,6 +103,7 @@ void wait_in_events (test_events_t &events_) { void *watch = zmq_stopwatch_start (); while (events_.in_events.get () < 1) { + msleep (1); #ifdef ZMQ_BUILD_DRAFT TEST_ASSERT_LESS_OR_EQUAL_MESSAGE (SETTLE_TIME, zmq_stopwatch_intermediate (watch), @@ -116,6 +117,7 @@ void wait_timer_events (test_events_t &events_) { void *watch = zmq_stopwatch_start (); while (events_.timer_events.get () < 1) { + msleep (1); #ifdef ZMQ_BUILD_DRAFT TEST_ASSERT_LESS_OR_EQUAL_MESSAGE (SETTLE_TIME, zmq_stopwatch_intermediate (watch),