diff options
-rw-r--r-- | src/threadpool.c | 11 | ||||
-rw-r--r-- | test/test-list.h | 2 | ||||
-rw-r--r-- | test/test-loop-close.c | 18 |
3 files changed, 4 insertions, 27 deletions
diff --git a/src/threadpool.c b/src/threadpool.c index ff64a3ae..10893411 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -38,6 +38,7 @@ static uv_thread_t* threads; static uv_thread_t default_threads[4]; static QUEUE exit_message; static QUEUE wq; +static volatile int initialized; static void uv__cancelled(struct uv__work* w) { @@ -104,7 +105,7 @@ static void post(QUEUE* q) { UV_DESTRUCTOR(static void cleanup(void)) { unsigned int i; - if (nthreads == 0) + if (initialized == 0) return; post(&exit_message); @@ -121,6 +122,7 @@ UV_DESTRUCTOR(static void cleanup(void)) { threads = NULL; nthreads = 0; + initialized = 0; } #endif @@ -128,7 +130,6 @@ UV_DESTRUCTOR(static void cleanup(void)) { static void init_threads(void) { unsigned int i; const char* val; - int spin; nthreads = ARRAY_SIZE(default_threads); val = getenv("UV_THREADPOOL_SIZE"); @@ -160,11 +161,7 @@ static void init_threads(void) { if (uv_thread_create(threads + i, worker, NULL)) abort(); - do { - uv_mutex_lock(&mutex); - spin = (idle_threads < nthreads); - uv_mutex_unlock(&mutex); - } while (spin); + initialized = 1; } diff --git a/test/test-list.h b/test/test-list.h index 8b530d44..2adbe6a0 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -28,7 +28,6 @@ TEST_DECLARE (run_once) TEST_DECLARE (run_nowait) TEST_DECLARE (loop_alive) TEST_DECLARE (loop_close) -TEST_DECLARE (loop_instant_close) TEST_DECLARE (loop_stop) TEST_DECLARE (loop_update_time) TEST_DECLARE (loop_backend_timeout) @@ -423,7 +422,6 @@ TASK_LIST_START TEST_ENTRY (run_nowait) TEST_ENTRY (loop_alive) TEST_ENTRY (loop_close) - TEST_ENTRY (loop_instant_close) TEST_ENTRY (loop_stop) TEST_ENTRY (loop_update_time) TEST_ENTRY (loop_backend_timeout) diff --git a/test/test-loop-close.c b/test/test-loop-close.c index f0f3e627..971c9d72 100644 --- a/test/test-loop-close.c +++ b/test/test-loop-close.c @@ -55,21 +55,3 @@ TEST_IMPL(loop_close) { return 0; } - -static void loop_instant_close_work_cb(uv_work_t* req) { -} - -static void loop_instant_close_after_work_cb(uv_work_t* req, int status) { -} - -TEST_IMPL(loop_instant_close) { - static uv_loop_t loop; - static uv_work_t req; - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(0 == uv_queue_work(&loop, - &req, - loop_instant_close_work_cb, - loop_instant_close_after_work_cb)); - MAKE_VALGRIND_HAPPY(); - return 0; -} |