summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 2cfceef936..9616cc2e38 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1193,17 +1193,16 @@ rb_thread_create_timer_thread(void)
pthread_attr_init(&attr);
#ifdef PTHREAD_STACK_MIN
- if (PTHREAD_STACK_MIN < 4096 * 3) {
+ {
+ const size_t min_size = (4096 * 4);
/* Allocate the machine stack for the timer thread
- * at least 12KB (3 pages). FreeBSD 8.2 AMD64 causes
- * machine stack overflow only with PTHREAD_STACK_MIN.
+ * at least 16KB (4 pages). FreeBSD 8.2 AMD64 causes
+ * machine stack overflow only with PTHREAD_STACK_MIN.
*/
- pthread_attr_setstacksize(&attr,
- 4096 * 3 + (THREAD_DEBUG ? BUFSIZ : 0));
- }
- else {
- pthread_attr_setstacksize(&attr,
- PTHREAD_STACK_MIN + (THREAD_DEBUG ? BUFSIZ : 0));
+ size_t stack_size = PTHREAD_STACK_MIN; /* may be dynamic, get only once */
+ if (stack_size < min_size) stack_size = min_size;
+ if (THREAD_DEBUG) stack_size += BUFSIZ;
+ pthread_attr_setstacksize(&attr, stack_size);
}
#endif