aboutsummaryrefslogtreecommitdiffstats
path: root/main/pmacct/stacksize.patch
blob: 3d2279166d2bf68a5717fa07bae2f9f89f20a210 (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
--- ./src/thread_pool.c.orig	2015-06-23 11:22:18.408373704 -0200
+++ ./src/thread_pool.c	2015-06-23 11:31:55.926972746 -0200
@@ -42,12 +42,15 @@
   #define pthread_mutex_unlock  debug_pthread_mutex_unlock
 #endif
 
+/* set default stack size to 1MB */
+#define PMACCT_STACKSIZE 1024*1014
 
 thread_pool_t *allocate_thread_pool(int count)
 {
   int i, rc;
   thread_pool_t *pool;
   thread_pool_item_t *worker;
+  pthread_attr_t attr, *attrptr = NULL;
 
   // Allocate pool
   pool = malloc(sizeof(thread_pool_t));
@@ -88,7 +91,19 @@
 
     /* Create the thread */
     worker->thread = malloc(sizeof(pthread_t));
-    rc = pthread_create(worker->thread, NULL, thread_runner, worker);
+    rc = pthread_attr_init(&attr);
+    if (rc) {
+      printf("ERROR: pthread_attr_init failed: %s\n", strerror(rc));
+    } else {
+        rc = pthread_attr_setstacksize(&attr, PMACCT_STACKSIZE);
+	if (rc) {
+          printf("ERROR: pthread_attr_setstack failed: %s\n", strerror(rc));
+        } else {
+          attrptr=&attr;
+        }
+    }
+
+    rc = pthread_create(worker->thread, attrptr, thread_runner, worker);
 
     if (rc) {
       printf("ERROR: thread creation failed: %s\n", strerror(rc));