From a4222614c4d8f0b2bc362b80cb4178fa5d0dcf52 Mon Sep 17 00:00:00 2001 From: Sean Bright <sean.bright@gmail.com> Date: Fri, 18 Oct 2019 14:47:20 -0400 Subject: [PATCH] utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN ASTERISK-28590 #close Change-Id: I51abce00c04d0a06550bda5205580705185b9c1c --- include/asterisk/utils.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index 4dc406db7f..2b332a51f0 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -423,8 +423,13 @@ int ast_careful_fwrite(FILE *f, int fd, const char *s, size_t len, int timeoutms * Thread management support (should be moved to lock.h or a different header) */ -#define AST_STACKSIZE (((sizeof(void *) * 8 * 8) - 16) * 1024) -#define AST_STACKSIZE_LOW (((sizeof(void *) * 8 * 2) - 16) * 1024) +#if defined(PTHREAD_STACK_MIN) +# define AST_STACKSIZE MAX((((sizeof(void *) * 8 * 8) - 16) * 1024), PTHREAD_STACK_MIN) +# define AST_STACKSIZE_LOW MAX((((sizeof(void *) * 8 * 2) - 16) * 1024), PTHREAD_STACK_MIN) +#else +# define AST_STACKSIZE (((sizeof(void *) * 8 * 8) - 16) * 1024) +# define AST_STACKSIZE_LOW (((sizeof(void *) * 8 * 2) - 16) * 1024) +#endif int ast_background_stacksize(void); -- GitLab