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

Piotr Sikora piotrsikora at google.com
Thu Jun 22 20:33:05 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 5f5d70428655db0889a2111d17d912a7383df152
# Parent  a39bc74873faf9e5bea616561b43f6ecc55229f9
Output chain: propagate last_buf flag to c->send_chain().

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

diff -r a39bc74873fa -r 5f5d70428655 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