From 9368782d5c96f08d61933e994789812e5e73260d Mon Sep 17 00:00:00 2001 From: Shia Date: Sun, 31 Dec 2023 13:51:10 +0900 Subject: [PATCH] Use max_cpu when RUBY_MAX_CPU given --- thread_pthread.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/thread_pthread.c b/thread_pthread.c index 7918d0d3d9b682..6d2f55a9573ed7 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1685,8 +1685,11 @@ ruby_mn_threads_params(void) const int default_max_cpu = 8; // TODO: CPU num? int max_cpu = default_max_cpu; - if (USE_MN_THREADS && max_cpu_cstr && (max_cpu = atoi(max_cpu_cstr)) > 0) { - max_cpu = default_max_cpu; + if (USE_MN_THREADS && max_cpu_cstr) { + int given_max_cpu = atoi(max_cpu_cstr); + if (given_max_cpu > 0) { + max_cpu = given_max_cpu; + } } vm->ractor.sched.max_cpu = max_cpu;