# HG changeset patch # User Igor Sysoev # Date 1188500384 0 # Node ID e498f4cb1663ecc58a77437a9f7d24d149ec74ca # Parent ccbf588fb5170cfb6650da412533c5d9dcf83e77 destroy ngx_cycle->pool on exit diff -r ccbf588fb517 -r e498f4cb1663 src/os/unix/ngx_process_cycle.c --- a/src/os/unix/ngx_process_cycle.c Thu Aug 30 18:57:38 2007 +0000 +++ b/src/os/unix/ngx_process_cycle.c Thu Aug 30 18:59:44 2007 +0000 @@ -62,6 +62,11 @@ static u_char master_process[] = "master process"; +static ngx_cycle_t ngx_exit_cycle; +static ngx_log_t ngx_exit_log; +static ngx_open_file_t ngx_exit_log_file; + + void ngx_master_process_cycle(ngx_cycle_t *cycle) { @@ -649,13 +654,21 @@ } /* - * we do not destroy cycle->pool here because a signal handler - * that uses cycle->log can be called at this point + * Copy ngx_cycle->log related data to the special static exit cycle, + * log, and log file structures enough to allow a signal handler to log. + * The handler may be called when standard ngx_cycle->log allocated from + * ngx_cycle->pool is already destroyed. */ -#if 0 + ngx_exit_log_file.fd = ngx_cycle->log->file->fd; + + ngx_exit_log = *ngx_cycle->log; + ngx_exit_log.file = &ngx_exit_log_file; + + ngx_exit_cycle.log = &ngx_exit_log; + ngx_cycle = &ngx_exit_cycle; + ngx_destroy_pool(cycle->pool); -#endif exit(0); } @@ -996,13 +1009,23 @@ } /* - * we do not destroy cycle->pool here because a signal handler - * that uses cycle->log can be called at this point + * Copy ngx_cycle->log related data to the special static exit cycle, + * log, and log file structures enough to allow a signal handler to log. + * The handler may be called when standard ngx_cycle->log allocated from + * ngx_cycle->pool is already destroyed. */ -#if 0 + ngx_exit_log_file.fd = ngx_cycle->log->file->fd; + + ngx_exit_log = *ngx_cycle->log; + ngx_exit_log.file = &ngx_exit_log_file; + + ngx_exit_cycle.log = &ngx_exit_log; + ngx_cycle = &ngx_exit_cycle; + ngx_destroy_pool(cycle->pool); -#endif + + ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, "exit"); exit(0); }