Skip to content

Commit

Permalink
Fix reload-on-touch/change (#2689)
Browse files Browse the repository at this point in the history
* Fix reload-on-touch/change

As part of a fix for #2656, commit 8f1d0e5 introduced a measure to wait
for processes to finish work while reloading. The code to do this
affects other logic flows was well, breaking the ability to reload uwsgi
when a config file changes.

This moves the code around a bit so #2656 stays fixed, but
reload-on-touch/change works again.

Fixes #2681.

* Apply suggestions from code review

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
  • Loading branch information
Lalufu and xrmx authored Oct 26, 2024
1 parent b738f55 commit e77e41b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 0 additions & 6 deletions core/master_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ void uwsgi_destroy_processes() {

uwsgi_detach_daemons();

for (i = 1; i <= uwsgi.numproc; i++) {
if (uwsgi.workers[i].pid > 0) {
waitpid(uwsgi.workers[i].pid, &waitpid_status, 0);
}
}

for (i = 0; i < ushared->gateways_cnt; i++) {
if (ushared->gateways[i].pid > 0) {
kill(ushared->gateways[i].pid, SIGKILL);
Expand Down
8 changes: 8 additions & 0 deletions core/uwsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,8 @@ void kill_them_all(int signum) {
// gracefully destroy
void gracefully_kill_them_all(int signum) {

int waitpid_status;

if (uwsgi_instance_is_dying) return;
uwsgi.status.gracefully_destroying = 1;

Expand All @@ -1377,6 +1379,12 @@ void gracefully_kill_them_all(int signum) {
}
}

for (i = 1; i <= uwsgi.numproc; i++) {
if (uwsgi.workers[i].pid > 0) {
waitpid(uwsgi.workers[i].pid, &waitpid_status, 0);
}
}

uwsgi_destroy_processes();
}

Expand Down

0 comments on commit e77e41b

Please sign in to comment.