diff --git a/core/master.c b/core/master.c index 33b43a7d..b82c10b9 100644 --- a/core/master.c +++ b/core/master.c @@ -170,10 +170,9 @@ void uwsgi_master_check_mercy() { for (i = 1; i <= uwsgi.numproc; i++) { if (uwsgi.workers[i].pid > 0 && uwsgi.workers[i].cursed_at) { if (uwsgi_now() > uwsgi.workers[i].no_mercy_at) { - uwsgi_log("worker %d (pid: %d) is taking too much time to die...NO MERCY !!!\n", i, uwsgi.workers[i].pid); - if (kill(uwsgi.workers[i].pid, SIGKILL)) { - uwsgi_error("uwsgi_master_check_mercy()/kill()"); - } + uwsgi_log_verbose("worker %d (pid: %d) is taking too much time to die...NO MERCY !!!\n", i, uwsgi.workers[i].pid); + // yes that look strangem but we avoid callign it again if we skip waitpid() call below + uwsgi_curse(i, SIGKILL); } } } diff --git a/core/master_utils.c b/core/master_utils.c index b86fe0fb..d637cbc2 100644 --- a/core/master_utils.c +++ b/core/master_utils.c @@ -586,6 +586,7 @@ int uwsgi_respawn_worker(int wid) { // reset wsgi_request structures for(i=0;iasync_id = tmp_id; + // yes, this is pretty useless but we cannot ensure all of the plugin have the same behaviour + uwsgi.workers[uwsgi.mywid].cores[wsgi_req->async_id].in_request = 0; + if (uwsgi.shared->options[UWSGI_OPTION_MAX_REQUESTS] > 0 && uwsgi.workers[uwsgi.mywid].delta_requests >= uwsgi.shared->options[UWSGI_OPTION_MAX_REQUESTS] && (end_of_request - (uwsgi.workers[uwsgi.mywid].last_spawn*1000000) >= uwsgi.shared->options[UWSGI_OPTION_MIN_WORKER_LIFETIME]*1000000)) { diff --git a/plugins/gevent/gevent.c b/plugins/gevent/gevent.c index 602d947f..9c1cf748 100644 --- a/plugins/gevent/gevent.c +++ b/plugins/gevent/gevent.c @@ -29,26 +29,30 @@ PyObject *py_uwsgi_gevent_graceful(PyObject *self, PyObject *args) { uwsgi_log("Gracefully killing worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid); uwsgi.workers[uwsgi.mywid].manage_next_request = 0; - uwsgi_log("stopping gevent signals watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid); + uwsgi_log_verbose("stopping gevent signals watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid); PyObject_CallMethod(ugevent.my_signal_watcher, "stop", NULL); PyObject_CallMethod(ugevent.signal_watcher, "stop", NULL); - uwsgi_log("stopping gevent sockets watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid); + uwsgi_log_verbose("stopping gevent sockets watchers for worker %d (pid: %d)...\n", uwsgi.mywid, uwsgi.mypid); int i,count = uwsgi_count_sockets(uwsgi.sockets); for(i=0;imethod_len, wsgi_req->method, wsgi_req->uri_len, wsgi_req->uri, + wsgi_req->remote_addr_len, wsgi_req->remote_addr); running_cores++; } } if (running_cores > 0) { - uwsgi_log("waiting for %d running requests...\n", running_cores); + uwsgi_log_verbose("waiting for %d running requests...\n", running_cores); } Py_INCREF(Py_None); @@ -162,6 +166,8 @@ edge: if (uwsgi_sock->retry && uwsgi_sock->retry[wsgi_req->async_id]) { goto edge; } + // in case of errors (or thundering herd, just rest it) + uwsgi.workers[uwsgi.mywid].cores[wsgi_req->async_id].in_request = 0; goto clear; }