[PATCH] Output chain: propagate flush and last_buf flags to send_chain()

Piotr Sikora piotrsikora at google.com
Sun Jun 4 03:04:07 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 2a48b9b6e67d91594c1787ebf721daebf5f88c91
# Parent  716852cce9136d977b81a2d1b8b6f9fbca0dce49
Output chain: propagate flush and last_buf flags to send_chain().

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

diff -r 716852cce913 -r 2a48b9b6e67d 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         flush;
     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);
 
+    flush = 0;
+
     for (cl = ctx->out; cl; cl = cl->next) {
 
 #if 1
@@ -732,9 +736,13 @@ ngx_chain_writer(void *data, ngx_chain_t
 #endif
 
         size += ngx_buf_size(cl->buf);
+
+        if (cl->buf->flush || cl->buf->last_buf) {
+            flush = 1;
+        }
     }
 
-    if (size == 0 && !c->buffered) {
+    if (size == 0 && !flush && !c->buffered) {
         return NGX_OK;
     }
 


More information about the nginx-devel mailing list