Test that loop refs going down to zero in a prepare callback does not hang the event loop

This commit is contained in:
Bert Belder 2011-07-21 14:53:40 +02:00
parent 9d8c9cce7c
commit 1ab28df433
2 changed files with 20 additions and 0 deletions

View File

@ -53,6 +53,7 @@ TEST_DECLARE (idle_ref)
TEST_DECLARE (async_ref)
TEST_DECLARE (prepare_ref)
TEST_DECLARE (check_ref)
TEST_DECLARE (unref_in_prepare_cb)
TEST_DECLARE (async)
TEST_DECLARE (get_currentexe)
TEST_DECLARE (hrtime)
@ -121,6 +122,7 @@ TASK_LIST_START
TEST_ENTRY (async_ref)
TEST_ENTRY (prepare_ref)
TEST_ENTRY (check_ref)
TEST_ENTRY (unref_in_prepare_cb)
TEST_ENTRY (loop_handles)

View File

@ -71,3 +71,21 @@ TEST_IMPL(check_ref) {
uv_run();
return 0;
}
static void prepare_cb(uv_prepare_t* handle, int status) {
ASSERT(handle != NULL);
ASSERT(status == 0);
uv_unref();
}
TEST_IMPL(unref_in_prepare_cb) {
uv_prepare_t h;
uv_init();
uv_prepare_init(&h);
uv_prepare_start(&h, prepare_cb);
uv_run();
return 0;
}