From a98839d7bfaef389804a146fbcbeab2ab767f0a0 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 28 May 2021 08:22:44 -0700 Subject: [PATCH] cleanup,win: Remove _WIN32 guards on threadpool Fixes: https://github.com/libuv/libuv/issues/2980 Refs: https://github.com/nodejs/node/pull/35021 Reviewed-By: Ben Noordhuis Reviewed-By: Anna Henningsen Reviewed-By: Jameson Nash --- src/threadpool.c | 2 -- src/uv-common.c | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/threadpool.c b/src/threadpool.c index 0998938f..869ae95f 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -161,7 +161,6 @@ static void post(QUEUE* q, enum uv__work_kind kind) { void uv__threadpool_cleanup(void) { -#ifndef _WIN32 unsigned int i; if (nthreads == 0) @@ -181,7 +180,6 @@ void uv__threadpool_cleanup(void) { threads = NULL; nthreads = 0; -#endif } diff --git a/src/uv-common.c b/src/uv-common.c index dd559a11..e81ed79b 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -872,7 +872,11 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { } -#ifdef __GNUC__ /* Also covers __clang__ and __INTEL_COMPILER. */ +/* Also covers __clang__ and __INTEL_COMPILER. Disabled on Windows because + * threads have already been forcibly terminated by the operating system + * by the time destructors run, ergo, it's not safe to try to clean them up. + */ +#if defined(__GNUC__) && !defined(_WIN32) __attribute__((destructor)) #endif void uv_library_shutdown(void) {