Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
test: fix a race condition in 'async' test
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Apr 17, 2012
1 parent 5345ee3 commit 20879c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/test-async.c
Expand Up @@ -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++;
Expand Down

0 comments on commit 20879c1

Please sign in to comment.