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