mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-06-16 02:15:48 +00:00
attempt to fix #1034
This commit is contained in:
@@ -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, ""} };
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user