changeset 1882:77cde56d41b6

Change Pthread thread creation logic to avoid Cygwin limitations with setting stack size
author Adam Chlipala <adam@chlipala.net>
date Mon, 14 Oct 2013 08:08:57 -0400
parents a5b08bdfa450
children 5125b1df6045
files src/c/request.c
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/request.c	Fri Oct 11 17:15:28 2013 -0400
+++ b/src/c/request.c	Mon Oct 14 08:08:57 2013 -0400
@@ -127,18 +127,20 @@
 
 int pthread_create_big(pthread_t *outThread, void *foo, void *threadFunc, void *arg)
 {
-  int err;
-  pthread_attr_t stackSizeAttribute;
+  if (stackSize > 0) {
+    int err;
+    pthread_attr_t stackSizeAttribute;
 
-  err = pthread_attr_init(&stackSizeAttribute);
-  if (err) return err; 
+    err = pthread_attr_init(&stackSizeAttribute);
+    if (err) return err;
 
-  if (stackSize > 0) {
     err = pthread_attr_setstacksize(&stackSizeAttribute, stackSize);
     if (err) return err;
+
+    return pthread_create(outThread, &stackSizeAttribute, threadFunc, arg);
+  } else {
+    return pthread_create(outThread, NULL, threadFunc, arg);
   }
-
-  return pthread_create(outThread, &stackSizeAttribute, threadFunc, arg);
 }
 
 void uw_request_init(uw_app *app, void *logger_data, uw_logger log_error, uw_logger log_debug) {