diff options
author | Valentin Bartenev <vbart@nginx.com> | 2014-08-25 13:41:31 +0400 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2014-08-25 13:41:31 +0400 |
commit | f9b99baed366b855cef24f3443be6337583ac0f3 (patch) | |
tree | a71265d2531f63e5940448b6fe495d681a6681ae /src | |
parent | 8b30fb7c9771e24543f7fcc82431a4741f6e9d48 (diff) | |
download | nginx-f9b99baed366b855cef24f3443be6337583ac0f3.tar.gz nginx-f9b99baed366b855cef24f3443be6337583ac0f3.zip |
Access log: cancel the flush timer on graceful shutdown.
Previously, it could prevent a worker process from exiting
for up to the configured flush timeout.
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_log_module.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c index cec77e749..04aa27fda 100644 --- a/src/http/modules/ngx_http_log_module.c +++ b/src/http/modules/ngx_http_log_module.c @@ -744,10 +744,23 @@ ngx_http_log_flush(ngx_open_file_t *file, ngx_log_t *log) static void ngx_http_log_flush_handler(ngx_event_t *ev) { + ngx_open_file_t *file; + ngx_http_log_buf_t *buffer; + ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "http log buffer flush handler"); - ngx_http_log_flush(ev->data, ev->log); + if (ev->timedout) { + ngx_http_log_flush(ev->data, ev->log); + return; + } + + /* cancel the flush timer for graceful shutdown */ + + file = ev->data; + buffer = file->data; + + buffer->event = NULL; } @@ -1411,6 +1424,7 @@ process_formats: buffer->event->data = log->file; buffer->event->handler = ngx_http_log_flush_handler; buffer->event->log = &cf->cycle->new_log; + buffer->event->cancelable = 1; buffer->flush = flush; } |