aboutsummaryrefslogtreecommitdiffstats
path: root/testing/openvswitch/0001-ovs-thread-Set-stacksize-to-1M.patch
blob: 9533c4a29d9b65d0cbbc752bc8f88aef1f1ff4f7 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From a298bd267fae3238bde1847292efd2da08ad5b34 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 25 Aug 2014 08:50:26 +0000
Subject: [PATCH] ovs-thread: Set stacksize to 1M

With musl libc the default stacksize is 80k which is too small and
makes it segfault.

We increase it to 1MB.
http://permalink.gmane.org/gmane.linux.network.openvswitch.general/5831

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 lib/ovs-thread.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
index fe6fb43..0522242 100644
--- a/lib/ovs-thread.c
+++ b/lib/ovs-thread.c
@@ -32,6 +32,9 @@
 #include "socket-util.h"
 #include "util.h"
 
+/* set default stack size to 1M */
+#define OVS_STACK_SIZE (1024 * 1024)
+
 #ifdef __CHECKER__
 /* Omit the definitions in this file because they are somewhat difficult to
  * write without prompting "sparse" complaints, without ugliness or
@@ -339,6 +342,7 @@ ovs_thread_create(const char *name, void *(*start)(void *), void *arg)
 {
     struct ovsthread_aux *aux;
     pthread_t thread;
+    pthread_attr_t attr;
     int error;
 
     forbid_forking("multiple threads exist");
@@ -350,6 +354,15 @@ ovs_thread_create(const char *name, void *(*start)(void *), void *arg)
     aux->arg = arg;
     ovs_strlcpy(aux->name, name, sizeof aux->name);
 
+    error = pthread_attr_init(&attr);
+    if (error) {
+        ovs_abort(error, "pthread_attr_init failed");
+    }
+    error = pthread_attr_setstacksize(&attr, OVS_STACK_SIZE);
+    if (error) {
+        ovs_abort(error, "pthread_attr_setstacksize failed");
+    }
+
     error = pthread_create(&thread, NULL, ovsthread_wrapper, aux);
     if (error) {
         ovs_abort(error, "pthread_create failed");
-- 
2.1.0