Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graceful stop worker when max_requests/realod_on_* #2615

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions core/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ void *uwsgi_get_loop(char *name) {

void simple_loop() {
uwsgi_loop_cores_run(simple_loop_run);
// Other threads may still run. Make sure they will stop.
methane marked this conversation as resolved.
Show resolved Hide resolved
uwsgi.workers[uwsgi.mywid].manage_next_request = 0;

if (uwsgi.workers[uwsgi.mywid].shutdown_sockets)
uwsgi_shutdown_all_sockets();
}
Expand All @@ -72,16 +75,6 @@ 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) {
Expand Down
5 changes: 5 additions & 0 deletions core/uwsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3718,6 +3718,11 @@ void uwsgi_ignition() {
}
}

// main thread waits other threads.
if (uwsgi.threads > 1) {
wait_for_threads();
}

// end of the process...
end_me(0);
}
Expand Down