test: fix a race condition in 'async' test
This commit is contained in:
parent
5345ee36f2
commit
20879c1cf2
@ -39,17 +39,21 @@ void thread_cb(void *arg) {
|
|||||||
int n;
|
int n;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
do {
|
for (;;) {
|
||||||
uv_mutex_lock(&mutex);
|
uv_mutex_lock(&mutex);
|
||||||
n = async_cb_called;
|
n = async_cb_called;
|
||||||
uv_mutex_unlock(&mutex);
|
uv_mutex_unlock(&mutex);
|
||||||
|
|
||||||
|
if (n == 3) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
r = uv_async_send(&async);
|
r = uv_async_send(&async);
|
||||||
ASSERT(r == 0);
|
ASSERT(r == 0);
|
||||||
}
|
}
|
||||||
while (n < 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void close_cb(uv_handle_t* handle) {
|
static void close_cb(uv_handle_t* handle) {
|
||||||
ASSERT(handle != NULL);
|
ASSERT(handle != NULL);
|
||||||
close_cb_called++;
|
close_cb_called++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user