diff --git a/core/loop.c b/core/loop.c index 2c856826e..0c4fc9f80 100644 --- a/core/loop.c +++ b/core/loop.c @@ -72,6 +72,16 @@ void uwsgi_loop_cores_run(void *(*func) (void *)) { } long y = 0; func((void *) y); + + // main thread waits other threads. + uwsgi.workers[uwsgi.mywid].manage_next_request = 0; + + for (i = 1; i < uwsgi.threads; i++) { + int ret = pthread_join(uwsgi.workers[uwsgi.mywid].cores[i].thread_id, NULL); + if (ret) { + uwsgi_log("pthread_join() = %d\n", ret); + } + } } void uwsgi_setup_thread_req(long core_id, struct wsgi_request *wsgi_req) { diff --git a/core/uwsgi.c b/core/uwsgi.c index 915528f7c..080c0ead7 100755 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -1319,14 +1319,11 @@ void end_me(int signum) { } static void simple_goodbye_cruel_world(const char *reason) { - - if (uwsgi.threads > 1 && !uwsgi_instance_is_dying) { - wait_for_threads(); - } - + int prev = uwsgi.workers[uwsgi.mywid].manage_next_request; uwsgi.workers[uwsgi.mywid].manage_next_request = 0; - uwsgi_log("...The work of process %d is done (%s). Seeya!\n", getpid(), (reason != NULL ? reason : "no reason given")); - exit(0); + if (prev) { // Avoid showing same message from all threads. + uwsgi_log("...The work of process %d is done (%s). Seeya!\n", getpid(), (reason != NULL ? reason : "no reason given")); + } } void goodbye_cruel_world(const char *reason_fmt, ...) {