diff --git a/plugins/rack/rack_plugin.c b/plugins/rack/rack_plugin.c index 74de0e7b..2b2cb0c5 100644 --- a/plugins/rack/rack_plugin.c +++ b/plugins/rack/rack_plugin.c @@ -259,7 +259,7 @@ int uwsgi_request(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req) { return -1; } - if (uwsgi_parse_vars(uwsgi, wsgi_req)) { + if (uwsgi_parse_vars(wsgi_req)) { uwsgi_log("Invalid RACK request. skip.\n"); return -1; } diff --git a/plugins/rack/uwsgiplugin.py b/plugins/rack/uwsgiplugin.py index 5ba1c251..c9ae8636 100644 --- a/plugins/rack/uwsgiplugin.py +++ b/plugins/rack/uwsgiplugin.py @@ -1,5 +1,6 @@ import os,sys NAME='rack' -CFLAGS = '-I' + os.popen("ruby -e \"require 'mkmf';print Config::CONFIG['archdir']\"").read().rstrip() -LDFLAGS = '-l' + os.popen("ruby -e \"require 'mkmf';print CONFIG['RUBY_SO_NAME']\"").read().rstrip() +#CFLAGS = '-I' + os.popen("/Users/roberto/RUBY/bin/ruby -e \"require 'mkmf';print Config::CONFIG['archdir']\"").read().rstrip() +CFLAGS = '-I/Users/roberto/RUBY//include/ruby-1.9.1 -DHAVE_STRUCT_TIMESPEC -DHAVE_STRUCT_TIMEZONE' +LDFLAGS = '-l' + os.popen("/Users/roberto/RUBY/bin/ruby -e \"require 'mkmf';print CONFIG['RUBY_SO_NAME']\"").read().rstrip() diff --git a/pyloader.c b/pyloader.c index 9c998d38..ab1b0cad 100644 --- a/pyloader.c +++ b/pyloader.c @@ -34,6 +34,10 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, int ne struct uwsgi_app *wi; + if (uwsgi.threads > 1) { + pthread_mutex_lock(&uwsgi.lock_pyloaders); + } + if (wsgi_req->script_name_len == 0) { wsgi_req->script_name = ""; if (!uwsgi.vhost) id = 0; @@ -55,6 +59,9 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, int ne if (uwsgi_get_app_id(mountpoint, strlen(mountpoint)) != -1) { uwsgi_log( "mountpoint %.*s already configured. skip.\n", strlen(mountpoint), mountpoint); free(mountpoint); + if (uwsgi.threads > 1) { + pthread_mutex_unlock(&uwsgi.lock_pyloaders); + } return -1; } @@ -251,6 +258,9 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, int ne } uwsgi_log("\n"); + if (uwsgi.threads > 1) { + pthread_mutex_unlock(&uwsgi.lock_pyloaders); + } return id; @@ -266,6 +276,9 @@ doh: PyThreadState_Swap(uwsgi.main_thread); } } + if (uwsgi.threads > 1) { + pthread_mutex_unlock(&uwsgi.lock_pyloaders); + } return -1; } diff --git a/uwsgi.c b/uwsgi.c index 7ad351ac..223ece90 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -969,6 +969,8 @@ int main(int argc, char *argv[], char *envp[]) { exit(1); } pthread_setspecific(uwsgi.ut_save_key, (void *) PyThreadState_Get()); + // initialize the mutexes + pthread_mutex_init(&uwsgi.lock_pyloaders, NULL); uwsgi.gil_get = gil_real_get; uwsgi.gil_release = gil_real_release; uwsgi.current_wsgi_req = threaded_current_wsgi_req; diff --git a/uwsgi.h b/uwsgi.h index 26846582..3036f3e3 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -807,6 +807,10 @@ struct uwsgi_server { struct wsgi_request* (*current_wsgi_req)(void); int close_on_exec; + +#ifdef UWSGI_THREADING + pthread_mutex_t lock_pyloaders; +#endif }; struct uwsgi_cluster_node {