attempt to fix #1034

This commit is contained in:
Unbit
2015-09-10 09:35:53 +02:00
parent cd24b11369
commit 33df0dbcc9
3 changed files with 11 additions and 3 deletions
+6 -3
View File
@@ -204,15 +204,18 @@ struct uwsgi_option uwsgi_python_options[] = {
/* this routine will be called after each fork to reinitialize the various locks */
void uwsgi_python_pthread_prepare(void) {
pthread_mutex_lock(&up.lock_pyloaders);
if (!up.is_dynamically_loading_an_app)
pthread_mutex_lock(&up.lock_pyloaders);
}
void uwsgi_python_pthread_parent(void) {
pthread_mutex_unlock(&up.lock_pyloaders);
if (!up.is_dynamically_loading_an_app)
pthread_mutex_unlock(&up.lock_pyloaders);
}
void uwsgi_python_pthread_child(void) {
pthread_mutex_init(&up.lock_pyloaders, NULL);
if (!up.is_dynamically_loading_an_app)
pthread_mutex_init(&up.lock_pyloaders, NULL);
}
PyMethodDef uwsgi_spit_method[] = { {"uwsgi_spit", py_uwsgi_spit, METH_VARARGS, ""} };
+3
View File
@@ -213,6 +213,9 @@ struct uwsgi_python {
int call_osafterfork;
int pre_initialized;
// when 1 we have the app-loading lock held
int is_dynamically_loading_an_app;
};
+2
View File
@@ -339,6 +339,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
// this part must be heavy locked in threaded modes
if (uwsgi.threads > 1) {
pthread_mutex_lock(&up.lock_pyloaders);
up.is_dynamically_loading_an_app = 1;
}
}
@@ -363,6 +364,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
if (wsgi_req->dynamic) {
if (uwsgi.threads > 1) {
up.is_dynamically_loading_an_app = 0;
pthread_mutex_unlock(&up.lock_pyloaders);
}
}