about summary refs log tree commit homepage
path: root/thrpool.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-04-19 16:20:42 -0700
committerEric Wong <normalperson@yhbt.net>2012-04-19 16:20:42 -0700
commitc529e30a531f80d3382a64dcebc710583c62861b (patch)
tree114e520dbd71163cd9ca26bf6cb80aac58b74a96 /thrpool.c
parentfc3062add1af8fadd4e9f7ef1de519db3654fa5b (diff)
downloadcmogstored-c529e30a531f80d3382a64dcebc710583c62861b.tar.gz
libkqueue appears to use a lot of stack, so just use
the default stack size to avoid unexplained segfaults.
Diffstat (limited to 'thrpool.c')
-rw-r--r--thrpool.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/thrpool.c b/thrpool.c
index 593993b..ae90e64 100644
--- a/thrpool.c
+++ b/thrpool.c
@@ -9,13 +9,15 @@
  * We also use syslog() and *printf() functions which take a lot of
  * stack under glibc, so we'll add BUFSIZ (8192 on glibc) to that
  */
-#define MOG_THR_STACK_SIZE ((16 * 1024) + MAX(8192,BUFSIZ))
-
-#if defined(PTHREAD_STACK_MIN) && (PTHREAD_STACK_MIN > MOG_THR_STACK_SIZE)
-#  undef MOG_THR_STACK_SIZE
-#  define MOG_THR_STACK_SIZE PTHREAD_STACK_MIN
+#if defined(LIBKQUEUE) && (LIBKQUEUE == 1)
+#  define MOG_THR_STACK_SIZE (0)
+#else
+#  define MOG_THR_STACK_SIZE ((16 * 1024) + MAX(8192,BUFSIZ))
+#  if defined(PTHREAD_STACK_MIN) && (PTHREAD_STACK_MIN > MOG_THR_STACK_SIZE)
+#    undef MOG_THR_STACK_SIZE
+#    define MOG_THR_STACK_SIZE PTHREAD_STACK_MIN
+#  endif
 #endif
-
 static const size_t stacksize = (size_t)MOG_THR_STACK_SIZE;
 
 void
@@ -34,7 +36,12 @@ mog_thrpool_start(struct mog_thrpool *tp, size_t n,
                 pthread_attr_t attr;
 
                 CHECK(int, 0, pthread_attr_init(&attr));
-                CHECK(int, 0, pthread_attr_setstacksize(&attr, stacksize));
+
+                if (stacksize > 0) {
+                        CHECK(int, 0,
+                              pthread_attr_setstacksize(&attr, stacksize));
+                }
+
                 CHECK(int, 0, pthread_create(thr, &attr, start_fn, arg));
                 CHECK(int, 0, pthread_attr_destroy(&attr));
         }