blob: e552ff9665fd6c09388ee23b7fe3c354d7fefb8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
From 3721cbececa18b369eb80176cb8aebe4beb99f1c Mon Sep 17 00:00:00 2001
From: Leandro Pereira <leandro@hardinfo.org>
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 <valgrind/valgrind.h>
#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");
|