[nginx] Access log: cancel the flush timer on graceful shutdown.

Valentin Bartenev vbart at nginx.com
Thu Oct 30 22:24:47 UTC 2014


details:   http://hg.nginx.org/nginx/rev/dff86e2246a5
branches:  
changeset: 5897:dff86e2246a5
user:      Valentin Bartenev <vbart at nginx.com>
date:      Mon Aug 25 13:41:31 2014 +0400
description:
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:

 src/http/modules/ngx_http_log_module.c |  16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diffs (36 lines):

diff -r 3efdd7788bb0 -r dff86e2246a5 src/http/modules/ngx_http_log_module.c
--- a/src/http/modules/ngx_http_log_module.c	Wed Aug 13 22:45:04 2014 +0400
+++ b/src/http/modules/ngx_http_log_module.c	Mon Aug 25 13:41:31 2014 +0400
@@ -744,10 +744,23 @@ ngx_http_log_flush(ngx_open_file_t *file
 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;
         }



More information about the nginx-devel mailing list