mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 09:42:39 +08:00
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.
This commit is contained in:
parent
8b30fb7c97
commit
f9b99baed3
@ -744,10 +744,23 @@ ngx_http_log_flush(ngx_open_file_t *file, ngx_log_t *log)
|
|||||||
static void
|
static void
|
||||||
ngx_http_log_flush_handler(ngx_event_t *ev)
|
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,
|
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0,
|
||||||
"http log buffer flush handler");
|
"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->data = log->file;
|
||||||
buffer->event->handler = ngx_http_log_flush_handler;
|
buffer->event->handler = ngx_http_log_flush_handler;
|
||||||
buffer->event->log = &cf->cycle->new_log;
|
buffer->event->log = &cf->cycle->new_log;
|
||||||
|
buffer->event->cancelable = 1;
|
||||||
|
|
||||||
buffer->flush = flush;
|
buffer->flush = flush;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user