From 1e4d41795caf0e6d95dcf1d37d98d0321fb6d00b Mon Sep 17 00:00:00 2001 From: "roberto@debian32" Date: Wed, 10 Aug 2011 12:13:46 +0200 Subject: [PATCH] allows setting threads stacksize --- uwsgi.c | 15 +++++++++++++++ uwsgi.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/uwsgi.c b/uwsgi.c index 39e55c73..2aea86f7 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -202,6 +202,8 @@ static struct option long_base_options[] = { {"mount", required_argument, 0, LONG_ARGS_MOUNT}, {"grunt", no_argument, &uwsgi.grunt, 1}, {"threads", required_argument, 0, LONG_ARGS_THREADS}, + {"threads-stacksize", required_argument, 0, LONG_ARGS_THREADS_STACKSIZE}, + {"thread-stacksize", required_argument, 0, LONG_ARGS_THREADS_STACKSIZE}, {"vhost", no_argument, &uwsgi.vhost, 1}, {"vhost-host", no_argument, 0, LONG_ARGS_VHOSTHOST}, #ifdef UWSGI_ROUTING @@ -1959,6 +1961,15 @@ skipzero: if (uwsgi.has_threads) { if (uwsgi.threads > 1) uwsgi.current_wsgi_req = threaded_current_wsgi_req; + (void) pthread_attr_init(&uwsgi.threads_attr); + if (uwsgi.threads_stacksize) { + if (pthread_attr_setstacksize(&uwsgi.threads_attr, uwsgi.threads_stacksize*1024) == 0) { + uwsgi_log("threads stack size set to %dk\n", uwsgi.threads_stacksize); + } + else { + uwsgi_log("!!! unable to set requested threads stacksize !!!\n"); + } + } for (i = 0; i < 0xFF; i++) { if (uwsgi.p[i]->enable_threads) uwsgi.p[i]->enable_threads(); @@ -2688,6 +2699,10 @@ static int manage_base_opt(int i, char *optarg) { uwsgi.has_threads = 1; uwsgi.threads = atoi(optarg); return 1; + case LONG_ARGS_THREADS_STACKSIZE: + uwsgi.has_threads = 1; + uwsgi.threads_stacksize = atoi(optarg); + return 1; #endif case LONG_ARGS_PROTOCOL: uwsgi.protocol = optarg; diff --git a/uwsgi.h b/uwsgi.h index d11cb41f..776649e5 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -475,6 +475,7 @@ struct uwsgi_opt { #define LONG_ARGS_CHOWN_SOCKET 17131 #define LONG_ARGS_HTTP_SOCKET 17132 #define LONG_ARGS_FASTCGI_SOCKET 17133 +#define LONG_ARGS_THREADS_STACKSIZE 17134 #define UWSGI_OK 0 @@ -1237,6 +1238,8 @@ struct uwsgi_server { struct uwsgi_core **core; int threads; + pthread_attr_t threads_attr; + size_t threads_stacksize; //this key old the u_request structure per core / thread pthread_key_t tur_key;