From 3721cbececa18b369eb80176cb8aebe4beb99f1c Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Mon, 22 Jan 2018 20:09:54 -0800 Subject: [PATCH] Pthread stack size should never be smaller than 16KiB Tis is a nasty hack to support Musl libc, which defines PTHREAD_STACK_MIN to 2048 bytes. A better approach might be asking pthread to give the actual stack size, and store this information somewhere that the coroutine library will have access to; maybe in the switcher struct. Patch-Source: https://github.com/lpereira/lwan/commit/3721cbececa18b369eb80176cb8aebe4beb99f1c, https://github.com/lpereira/lwan/commit/c5f5222a7c39d50c25348037b3d26716fbd6888b diff --git a/src/lib/lwan-coro.c b/src/lib/lwan-coro.c index 30be461..b3dfa54 100644 --- a/src/lib/lwan-coro.c +++ b/src/lib/lwan-coro.c @@ -34,7 +34,11 @@ #include #endif -#define CORO_STACK_MIN ((3 * (PTHREAD_STACK_MIN)) / 2) +#if PTHREAD_STACK_MIN <= 16384 +# undef PTHREAD_STACK_MIN +# define PTHREAD_STACK_MIN 16384 +#endif +#define CORO_STACK_MIN ((3 * (PTHREAD_STACK_MIN)) / 2) static_assert(DEFAULT_BUFFER_SIZE < (CORO_STACK_MIN + PTHREAD_STACK_MIN), "Request buffer fits inside coroutine stack");