unix,win: look up UV_THREADPOOL_SIZE with uv_os_getenv (#4888)

Use libuv's OS-independent implementation to look up UV_THREADPOOL_SIZE.

Fixes: https://github.com/libuv/libuv/issues/4887
This commit is contained in:
moe li 2025-09-15 00:14:44 +08:00 committed by GitHub
parent 47611f7855
commit 271d173b6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -194,11 +194,21 @@ void uv__threadpool_cleanup(void) {
static void init_threads(void) {
uv_thread_options_t config;
unsigned int i;
size_t buflen;
char buf[16];
const char* val;
int err;
uv_sem_t sem;
nthreads = ARRAY_SIZE(default_threads);
val = getenv("UV_THREADPOOL_SIZE");
buflen = ARRAY_SIZE(buf);
err = uv_os_getenv("UV_THREADPOOL_SIZE", buf, &buflen);
val = NULL;
if (err == 0)
val = buf;
if (val != NULL)
nthreads = atoi(val);
if (nthreads == 0)