1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2018-01-09 11:52:17 +00:00
parent 4928900814
commit 0b3dfa087b

View file

@ -1596,6 +1596,7 @@ rb_thread_create_timer_thread(void)
} }
# ifdef PTHREAD_STACK_MIN # ifdef PTHREAD_STACK_MIN
{ {
size_t stack_min = PTHREAD_STACK_MIN; /* may be dynamic, get only once */
const size_t min_size = (4096 * 4); const size_t min_size = (4096 * 4);
/* Allocate the machine stack for the timer thread /* Allocate the machine stack for the timer thread
* at least 16KB (4 pages). FreeBSD 8.2 AMD64 causes * at least 16KB (4 pages). FreeBSD 8.2 AMD64 causes
@ -1609,9 +1610,11 @@ rb_thread_create_timer_thread(void)
THREAD_DEBUG != 0 THREAD_DEBUG != 0
#endif #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 (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); err = pthread_attr_setstacksize(&attr, stack_size);
if (err != 0) { if (err != 0) {
rb_bug("pthread_attr_setstacksize(.., %"PRIuSIZE") failed: %s", rb_bug("pthread_attr_setstacksize(.., %"PRIuSIZE") failed: %s",