mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-05 21:21:53 +00:00
add pthread locking for init_uwsgi_app
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
+13
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user