diff --git a/buildconf/default.ini b/buildconf/default.ini index f36b4d1f..47217e31 100644 --- a/buildconf/default.ini +++ b/buildconf/default.ini @@ -18,7 +18,7 @@ async = true evdis = false ldap = auto pcre = auto -debug = false +debug = true unbit = false xml_implementation = libxml2 yaml_implementation = auto diff --git a/master.c b/master.c index cea4bfd9..42fff007 100644 --- a/master.c +++ b/master.c @@ -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); } } diff --git a/master_utils.c b/master_utils.c index 78b07174..47fdce1f 100644 --- a/master_utils.c +++ b/master_utils.c @@ -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) { diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index 55830921..59860a80 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -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 = ""; } diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index c971565c..8683cd56 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -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; + } } } diff --git a/uwsgi.c b/uwsgi.c index 1461409c..e3546e2b 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -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); diff --git a/uwsgi.h b/uwsgi.h index 4b87558f..3343b153 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -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 *);