summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-09 11:52:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-09 11:52:17 +0000
commit0b3dfa087bbe192aa43f3d3d84f214c1fdb0d814 (patch)
treed30055b22a291111919c01a1a2bee10792d385e2 /thread_pthread.c
parent4928900814725b6682c7aae5cf02ed60b3b32e57 (diff)
thread_pthread.c: round stack size
* thread_pthread.c (rb_thread_create_timer_thread): round up additional stack size to PTHREAD_STACK_MIN, to get rid of EINVAL at pthread_attr_setstacksize(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 3f4310dbfb..0313ac8b00 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1596,6 +1596,7 @@ rb_thread_create_timer_thread(void)
}
# ifdef PTHREAD_STACK_MIN
{
+ size_t stack_min = PTHREAD_STACK_MIN; /* may be dynamic, get only once */
const size_t min_size = (4096 * 4);
/* Allocate the machine stack for the timer thread
* at least 16KB (4 pages). FreeBSD 8.2 AMD64 causes
@@ -1609,9 +1610,11 @@ rb_thread_create_timer_thread(void)
THREAD_DEBUG != 0
#endif
};
- stack_size = PTHREAD_STACK_MIN; /* may be dynamic, get only once */
+ stack_size = stack_min;
if (stack_size < min_size) stack_size = min_size;
- if (needs_more_stack) stack_size += BUFSIZ;
+ if (needs_more_stack) {
+ stack_size += +((BUFSIZ - 1) / stack_min + 1) * stack_min;
+ }
err = pthread_attr_setstacksize(&attr, stack_size);
if (err != 0) {
rb_bug("pthread_attr_setstacksize(.., %"PRIuSIZE") failed: %s",