From 49616e4e17bf3e9417992cf177e5bccc1a8cc891 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 30 Nov 2017 00:09:42 +0100 Subject: [PATCH] Revert "unix,win: wait for threads to start" Reverted for suspected regressions in the Node.js test suite on Windows. Also revert e99ac4c1f4 ("test: add threadpool init/teardown test") since it depends on 5486f6bd51. This reverts commit 5486f6bd517382284109ff2f5355b61de417c4e8. This reverts commit e99ac4c1f4eb3b049a9e147cb53a666506858121. PR-URL: https://github.com/libuv/libuv/pull/1656 Refs: https://github.com/libuv/libuv/pull/1639 Reviewed-By: Colin Ihrig --- src/threadpool.c | 11 ++++------- test/test-list.h | 2 -- test/test-loop-close.c | 18 ------------------ 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/threadpool.c b/src/threadpool.c index ff64a3aee..108934112 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 8b530d44b..2adbe6a01 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 f0f3e627f..971c9d725 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; -}