mirror of
https://github.com/openresty/openresty
synced 2024-11-09 18:35:51 +01:00
54 lines
1.8 KiB
C
54 lines
1.8 KiB
C
--- nginx-1.11.2/src/os/unix/ngx_process_cycle.c 2016-07-05 08:56:16.000000000 -0700
|
|
+++ nginx-1.11.2-patched/src/os/unix/ngx_process_cycle.c 2017-05-14 09:59:52.301108274 -0700
|
|
@@ -304,11 +304,29 @@ ngx_single_process_cycle(ngx_cycle_t *cy
|
|
}
|
|
|
|
for ( ;; ) {
|
|
+ if (ngx_exiting) {
|
|
+ ngx_event_cancel_timers();
|
|
+
|
|
+ if (ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
|
|
+ {
|
|
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
|
|
+
|
|
+ for (i = 0; cycle->modules[i]; i++) {
|
|
+ if (cycle->modules[i]->exit_process) {
|
|
+ cycle->modules[i]->exit_process(cycle);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ ngx_master_process_exit(cycle);
|
|
+ }
|
|
+ }
|
|
+
|
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
|
|
|
|
ngx_process_events_and_timers(cycle);
|
|
|
|
- if (ngx_terminate || ngx_quit) {
|
|
+ if (ngx_terminate) {
|
|
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
|
|
|
|
for (i = 0; cycle->modules[i]; i++) {
|
|
if (cycle->modules[i]->exit_process) {
|
|
@@ -319,6 +337,19 @@ ngx_single_process_cycle(ngx_cycle_t *cy
|
|
ngx_master_process_exit(cycle);
|
|
}
|
|
|
|
+ if (ngx_quit) {
|
|
+ ngx_quit = 0;
|
|
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
|
|
+ "gracefully shutting down");
|
|
+ ngx_setproctitle("process is shutting down");
|
|
+
|
|
+ if (!ngx_exiting) {
|
|
+ ngx_exiting = 1;
|
|
+ ngx_close_listening_sockets(cycle);
|
|
+ ngx_close_idle_connections(cycle);
|
|
+ }
|
|
+ }
|
|
+
|
|
if (ngx_reconfigure) {
|
|
ngx_reconfigure = 0;
|
|
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring");
|