mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-08-26 16:28:00 +00:00
better master threading
This commit is contained in:
@@ -481,10 +481,13 @@ void master_loop(char **argv, char **environ) {
|
||||
}
|
||||
}
|
||||
|
||||
// fixup
|
||||
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
if (uwsgi.p[i]->master_fixup)
|
||||
uwsgi.p[i]->master_fixup();
|
||||
}
|
||||
if (uwsgi.p[i]->master_fixup) {
|
||||
uwsgi.p[i]->master_fixup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (;;) {
|
||||
|
||||
@@ -4,6 +4,7 @@ extern struct uwsgi_server uwsgi;
|
||||
extern struct uwsgi_python up;
|
||||
|
||||
void gil_real_get() {
|
||||
uwsgi_log("LOCK %d\n", uwsgi.mywid);
|
||||
#ifndef PYTHREE
|
||||
PyEval_AcquireLock();
|
||||
PyThreadState_Swap((PyThreadState *) pthread_getspecific(up.upt_gil_key));
|
||||
@@ -13,6 +14,7 @@ void gil_real_get() {
|
||||
}
|
||||
|
||||
void gil_real_release() {
|
||||
uwsgi_log("UNLOCK %d\n", uwsgi.mywid);
|
||||
#ifndef PYTHREE
|
||||
pthread_setspecific(up.upt_gil_key, (void *) PyThreadState_Swap(NULL));
|
||||
PyEval_ReleaseLock();
|
||||
|
||||
@@ -828,6 +828,13 @@ void uwsgi_python_init_apps() {
|
||||
|
||||
}
|
||||
|
||||
void uwsgi_python_master_fixup() {
|
||||
|
||||
if (uwsgi.has_threads) {
|
||||
UWSGI_RELEASE_GIL;
|
||||
}
|
||||
}
|
||||
|
||||
void uwsgi_python_enable_threads() {
|
||||
|
||||
PyEval_InitThreads();
|
||||
@@ -853,13 +860,6 @@ void uwsgi_python_enable_threads() {
|
||||
|
||||
}
|
||||
|
||||
void uwsgi_python_master_fixup() {
|
||||
|
||||
if (uwsgi.has_threads) {
|
||||
UWSGI_RELEASE_GIL;
|
||||
}
|
||||
}
|
||||
|
||||
void uwsgi_python_init_thread(int core_id) {
|
||||
|
||||
// set a new ThreadState for each thread
|
||||
@@ -1088,6 +1088,7 @@ struct uwsgi_plugin python_plugin = {
|
||||
.init_apps = uwsgi_python_init_apps,
|
||||
|
||||
.fixup = uwsgi_python_fixup,
|
||||
.master_fixup = uwsgi_python_master_fixup,
|
||||
|
||||
.mount_app = uwsgi_python_mount_app,
|
||||
|
||||
@@ -1095,8 +1096,6 @@ struct uwsgi_plugin python_plugin = {
|
||||
.init_thread = uwsgi_python_init_thread,
|
||||
.manage_xml = uwsgi_python_xml,
|
||||
|
||||
.master_fixup = uwsgi_python_master_fixup,
|
||||
|
||||
.magic = uwsgi_python_magic,
|
||||
|
||||
.suspend = uwsgi_python_suspend,
|
||||
|
||||
@@ -557,7 +557,6 @@ struct uwsgi_plugin {
|
||||
int (*init) (void);
|
||||
void (*post_init) (void);
|
||||
void (*post_fork) (void);
|
||||
void (*master_fixup) (void);
|
||||
struct option *options;
|
||||
const char *short_options;
|
||||
int (*manage_opt) (int, char *);
|
||||
@@ -567,6 +566,7 @@ struct uwsgi_plugin {
|
||||
void (*after_request) (struct wsgi_request *);
|
||||
void (*init_apps) (void);
|
||||
void (*fixup) (void);
|
||||
void (*master_fixup) (void);
|
||||
int (*mount_app) (char *, char *);
|
||||
int (*manage_udp) (char *, int, char *, int);
|
||||
int (*manage_xml) (char *, char *);
|
||||
|
||||
Reference in New Issue
Block a user