Skip to content

Commit 271d173

Browse files
authored
unix,win: look up UV_THREADPOOL_SIZE with uv_os_getenv (libuv#4888)
Use libuv's OS-independent implementation to look up UV_THREADPOOL_SIZE. Fixes: libuv#4887
1 parent 47611f7 commit 271d173

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/threadpool.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,21 @@ void uv__threadpool_cleanup(void) {
194194
static void init_threads(void) {
195195
uv_thread_options_t config;
196196
unsigned int i;
197+
size_t buflen;
198+
char buf[16];
197199
const char* val;
200+
int err;
201+
198202
uv_sem_t sem;
199203

200204
nthreads = ARRAY_SIZE(default_threads);
201-
val = getenv("UV_THREADPOOL_SIZE");
205+
206+
buflen = ARRAY_SIZE(buf);
207+
err = uv_os_getenv("UV_THREADPOOL_SIZE", buf, &buflen);
208+
val = NULL;
209+
if (err == 0)
210+
val = buf;
211+
202212
if (val != NULL)
203213
nthreads = atoi(val);
204214
if (nthreads == 0)

0 commit comments

Comments
 (0)