projects/aports·blob master · refs

33 lines · 1.2 KiB

1From 3721cbececa18b369eb80176cb8aebe4beb99f1c Mon Sep 17 00:00:00 2001
2From: Leandro Pereira <[email protected]>
3Date: Mon, 22 Jan 2018 20:09:54 -0800
4Subject: [PATCH] Pthread stack size should never be smaller than 16KiB
5
6Tis is a nasty hack to support Musl libc, which defines
7PTHREAD_STACK_MIN to 2048 bytes.
8
9A better approach might be asking pthread to give the
10actual stack size, and store this information somewhere
11that the coroutine library will have access to; maybe
12in the switcher struct.
13
14Patch-Source: https://github.com/lpereira/lwan/commit/3721cbececa18b369eb80176cb8aebe4beb99f1c,
15 https://github.com/lpereira/lwan/commit/c5f5222a7c39d50c25348037b3d26716fbd6888b
16
17diff --git a/src/lib/lwan-coro.c b/src/lib/lwan-coro.c
18index 30be461..b3dfa54 100644
19--- a/src/lib/lwan-coro.c
20+++ b/src/lib/lwan-coro.c
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");