master_fixup on reloads

This commit is contained in:
roberto@goyle
2011-06-24 07:41:01 +02:00
parent 283904107f
commit 789e333736
7 changed files with 28 additions and 6 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ async = true
evdis = false
ldap = auto
pcre = auto
debug = false
debug = true
unbit = false
xml_implementation = libxml2
yaml_implementation = auto
+1 -1
View File
@@ -485,7 +485,7 @@ void master_loop(char **argv, char **environ) {
for (i = 0; i < 0xFF; i++) {
if (uwsgi.p[i]->master_fixup) {
uwsgi.p[i]->master_fixup();
uwsgi.p[i]->master_fixup(0);
}
}
+9
View File
@@ -35,6 +35,7 @@ void master_check_cluster_nodes() {
int uwsgi_respawn_worker(int wid) {
int respawns = uwsgi.workers[wid].respawn_count;
int i;
pid_t pid = fork();
@@ -51,6 +52,14 @@ int uwsgi_respawn_worker(int wid) {
uwsgi.workers[uwsgi.mywid].respawn_count++;
uwsgi.workers[uwsgi.mywid].last_spawn = uwsgi.current_time;
uwsgi.workers[uwsgi.mywid].manage_next_request = 1;
if (uwsgi.master_process && uwsgi.workers[uwsgi.mywid].respawn_count > 1) {
for (i = 0; i < 0xFF; i++) {
if (uwsgi.p[i]->master_fixup) {
uwsgi.p[i]->master_fixup(1);
}
}
}
return 1;
}
else if (pid < 1) {
-1
View File
@@ -38,7 +38,6 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, PyThre
struct uwsgi_app *wi;
if (wsgi_req->script_name_len == 0) {
wsgi_req->script_name = "";
}
+11 -2
View File
@@ -162,6 +162,8 @@ void uwsgi_python_reset_random_seed() {
void uwsgi_python_post_fork() {
uwsgi_log("POST FORK %d\n", uwsgi.mywid);
uwsgi_python_reset_random_seed();
#ifdef UWSGI_EMBEDDED
@@ -176,6 +178,8 @@ void uwsgi_python_post_fork() {
PyErr_Clear();
#endif
uwsgi_log("RELEASING GIL %d\n", uwsgi.mywid);
UWSGI_RELEASE_GIL
}
@@ -828,10 +832,15 @@ void uwsgi_python_init_apps() {
}
void uwsgi_python_master_fixup() {
void uwsgi_python_master_fixup(int step) {
if (uwsgi.has_threads) {
UWSGI_RELEASE_GIL;
if (step == 0) {
UWSGI_RELEASE_GIL;
}
else {
UWSGI_GET_GIL;
}
}
}
+5
View File
@@ -2063,6 +2063,8 @@ int uwsgi_start(void *v_argv) {
//from now on the process is a real worker
}
uwsgi_log("running workers...\n");
uwsgi_sock = uwsgi.sockets;
while (uwsgi_sock) {
struct uwsgi_string_list *usl = uwsgi.map_socket;
@@ -2184,12 +2186,15 @@ int uwsgi_start(void *v_argv) {
uwsgi_init_all_apps();
}
uwsgi_log("post fork hook %d\n", uwsgi.mywid);
for (i = 0; i < 0xFF; i++) {
if (uwsgi.p[i]->post_fork) {
uwsgi.p[i]->post_fork();
}
}
uwsgi_log("post fork hook DONE %d\n", uwsgi.mywid);
#ifdef UWSGI_ZEROMQ
if (uwsgi.zmq_receiver && uwsgi.zmq_responder) {
uwsgi.zmq_context = zmq_init(1);
+1 -1
View File
@@ -566,7 +566,7 @@ struct uwsgi_plugin {
void (*after_request) (struct wsgi_request *);
void (*init_apps) (void);
void (*fixup) (void);
void (*master_fixup) (void);
void (*master_fixup) (int);
int (*mount_app) (char *, char *);
int (*manage_udp) (char *, int, char *, int);
int (*manage_xml) (char *, char *);