From 50717794aff7ce1385fc232dcc1357b45ec3ce39 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 28 Jun 2020 11:31:37 +0800 Subject: [PATCH] bugfix: nginx would crash when receiving SIGHUP in the single process mode. Signed-off-by: Yichun Zhang (agentzh) --- ...-1.17.8-single_process_graceful_exit.patch | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/patches/nginx-1.17.8-single_process_graceful_exit.patch b/patches/nginx-1.17.8-single_process_graceful_exit.patch index 095e7ff..2754fc2 100644 --- a/patches/nginx-1.17.8-single_process_graceful_exit.patch +++ b/patches/nginx-1.17.8-single_process_graceful_exit.patch @@ -1,8 +1,30 @@ +diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c +index 15680237..12a8c687 100644 +--- a/src/os/unix/ngx_process.c ++++ b/src/os/unix/ngx_process.c +@@ -362,8 +362,15 @@ ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext) + break; + + case ngx_signal_value(NGX_RECONFIGURE_SIGNAL): +- ngx_reconfigure = 1; +- action = ", reconfiguring"; ++ if (ngx_process == NGX_PROCESS_SINGLE) { ++ ngx_terminate = 1; ++ action = ", exiting"; ++ ++ } else { ++ ngx_reconfigure = 1; ++ action = ", reconfiguring"; ++ } ++ + break; + + case ngx_signal_value(NGX_REOPEN_SIGNAL): diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c -index 1710ea81..b379da9c 100644 +index 5817a2c2..f3d58e97 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c -@@ -304,11 +304,26 @@ ngx_single_process_cycle(ngx_cycle_t *cycle) +@@ -305,11 +305,26 @@ ngx_single_process_cycle(ngx_cycle_t *cycle) } for ( ;; ) { @@ -30,7 +52,7 @@ index 1710ea81..b379da9c 100644 for (i = 0; cycle->modules[i]; i++) { if (cycle->modules[i]->exit_process) { -@@ -319,6 +334,20 @@ ngx_single_process_cycle(ngx_cycle_t *cycle) +@@ -320,6 +335,20 @@ ngx_single_process_cycle(ngx_cycle_t *cycle) ngx_master_process_exit(cycle); }