allows setting threads stacksize

This commit is contained in:
roberto@debian32
2011-08-10 12:13:46 +02:00
parent e2e973a20e
commit 1e4d41795c
2 changed files with 18 additions and 0 deletions
+15
View File
@@ -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;
+3
View File
@@ -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;