test: work around valgrind bug

This commit is contained in:
Ben Noordhuis 2012-11-09 01:57:58 +01:00
parent 43d52c77ba
commit 2d1f17fecb

View File

@ -50,6 +50,21 @@ void thread_cb(void *arg) {
r = uv_async_send(&async);
ASSERT(r == 0);
/* Work around a bug in Valgrind.
*
* Valgrind runs threads not in parallel but sequentially, i.e. one after
* the other. It also doesn't preempt them, instead it depends on threads
* yielding voluntarily by making a syscall.
*
* That never happens here: the pipe that is associated with the async
* handle is written to once but that's too early for Valgrind's scheduler
* to kick in. Afterwards, the thread busy-loops, starving the main thread.
* Therefore, we yield.
*
* This behavior has been observed with Valgrind 3.7.0 and 3.9.0.
*/
uv_sleep(0);
}
}