[PATCH] Output chain: propagate last_buf flag to c->send_chain()

Piotr Sikora piotrsikora at google.com
Sat Jun 17 20:59:44 UTC 2017


# HG changeset patch
# User Piotr Sikora <piotrsikora at google.com>
# Date 1491708381 25200
#      Sat Apr 08 20:26:21 2017 -0700
# Node ID 3363bdf821c7110b577437bd59c962653f3a144f
# Parent  d1816a2696de8c2faa1cd913a151e5f62a8620f3
Output chain: propagate last_buf flag to c->send_chain().

Signed-off-by: Piotr Sikora <piotrsikora at google.com>

diff -r d1816a2696de -r 3363bdf821c7 src/core/ngx_output_chain.c
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -658,6 +658,7 @@ ngx_chain_writer(void *data, ngx_chain_t
     ngx_chain_writer_ctx_t *ctx = data;
 
     off_t              size;
+    ngx_uint_t         last;
     ngx_chain_t       *cl, *ln, *chain;
     ngx_connection_t  *c;
 
@@ -689,9 +690,10 @@ ngx_chain_writer(void *data, ngx_chain_t
 
         size += ngx_buf_size(in->buf);
 
-        ngx_log_debug2(NGX_LOG_DEBUG_CORE, c->log, 0,
-                       "chain writer buf fl:%d s:%uO",
-                       in->buf->flush, ngx_buf_size(in->buf));
+        ngx_log_debug3(NGX_LOG_DEBUG_CORE, c->log, 0,
+                       "chain writer buf fl:%d l:%d s:%uO",
+                       in->buf->flush, in->buf->last_buf,
+                       ngx_buf_size(in->buf));
 
         cl = ngx_alloc_chain_link(ctx->pool);
         if (cl == NULL) {
@@ -707,6 +709,8 @@ ngx_chain_writer(void *data, ngx_chain_t
     ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
                    "chain writer in: %p", ctx->out);
 
+    last = 0;
+
     for (cl = ctx->out; cl; cl = cl->next) {
 
 #if 1
@@ -732,9 +736,16 @@ ngx_chain_writer(void *data, ngx_chain_t
 #endif
 
         size += ngx_buf_size(cl->buf);
+
+        if (cl->buf->last_buf) {
+            last = 1;
+        }
     }
 
-    if (size == 0 && !c->buffered) {
+    if (size == 0
+        && !c->buffered
+        && !(last && c->need_last_buf))
+    {
         return NGX_OK;
     }
 


More information about the nginx-devel mailing list