summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-12-13 11:52:19 +0900
committerNobuyoshi Nakada <[email protected]>2024-12-18 11:12:34 +0900
commit57f6329ba7aa744101efe026bea0a0bd46c77fc8 (patch)
treedfc3f2abff26496b2525c059f3bfde3d2529cfe1 /thread.c
parentc07fb791504cdfa32ff1be165758fcc624b26c2d (diff)
Check RUBY_THREAD_TIMESLICE value
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12328
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index 2d2951d18a..961e604856 100644
--- a/thread.c
+++ b/thread.c
@@ -5511,7 +5511,13 @@ Init_Thread(void)
const char * ptr = getenv("RUBY_THREAD_TIMESLICE");
if (ptr) {
- thread_default_quantum_ms = (uint32_t)strtol(ptr, NULL, 0);
+ long quantum = strtol(ptr, NULL, 0);
+ if (quantum > 0 && quantum <= UINT32_MAX) {
+ thread_default_quantum_ms = (uint32_t)quantum;
+ }
+ else if (0) {
+ fprintf(stderr, "Ignored RUBY_THREAD_TIMESLICE=%s\n", ptr);
+ }
}
{