From 20879c1cf29a6312761d9671357eb12cb8958a80 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 18 Apr 2012 01:14:30 +0200 Subject: [PATCH] test: fix a race condition in 'async' test --- test/test-async.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/test-async.c b/test/test-async.c index c6bd71b9..7cdad098 100644 --- a/test/test-async.c +++ b/test/test-async.c @@ -39,17 +39,21 @@ void thread_cb(void *arg) { int n; int r; - do { + for (;;) { uv_mutex_lock(&mutex); n = async_cb_called; uv_mutex_unlock(&mutex); + if (n == 3) { + break; + } + r = uv_async_send(&async); ASSERT(r == 0); } - while (n < 3); } + static void close_cb(uv_handle_t* handle) { ASSERT(handle != NULL); close_cb_called++;