You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bn...@apache.org on 2026/10/19 21:15:18 UTC

(trafficserver) 15/22: Size chunked passthrough writes without dropped trailers

This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 09c85d19f55da7d5974fc7a218164ea3cdc4d9fa
Author: Damian Meden <dm...@apache.org>
AuthorDate: Fri Sep 25 13:22:45 2026 -0500

    Size chunked passthrough writes without dropped trailers
    
    When a chunked response passes through with its trailers dropped
    (proxy.config.http.drop_chunked_trailers, on by default), the tunnel
    sized the consumer's write VIO from the bytes it consumed from the
    origin. That count includes the trailer bytes that were stripped and
    never written, so the write VIO waited for data that would never arrive
    and the response stalled until a timeout closed the connection.
    
    This patch sizes the write from the bytes actually written out when
    trailers are dropped. The fix was part of the early POST return change
    and is kept on its own now that the rest of that change has been
    backed out.
    
    Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
---
 src/proxy/http/HttpTunnel.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/proxy/http/HttpTunnel.cc b/src/proxy/http/HttpTunnel.cc
index 1aba464157..98f4a4ef27 100644
--- a/src/proxy/http/HttpTunnel.cc
+++ b/src/proxy/http/HttpTunnel.cc
@@ -1904,7 +1904,14 @@ HttpTunnel::final_consumer_bytes_to_write(HttpTunnelProducer *p, HttpTunnelConsu
       } else if (action == TunnelChunkingAction_t::DECHUNK_CONTENT) {
         bytes_to_write = p->chunked_handler.skip_bytes + p->chunked_handler.dechunked_size;
       } else if (action == TunnelChunkingAction_t::PASSTHRU_CHUNKED_CONTENT) {
-        bytes_to_write = p->bytes_consumed;
+        // Dropped trailers are counted in bytes_consumed but never reach the
+        // consumer buffer, so a write VIO sized from it waits for bytes that
+        // will never arrive. chunked_size counts only what was written out.
+        if (p->chunked_handler.drop_chunked_trailers) {
+          bytes_to_write = p->chunked_handler.skip_bytes + p->chunked_handler.chunked_size;
+        } else {
+          bytes_to_write = p->bytes_consumed;
+        }
       } else {
         bytes_to_write = p->bytes_consumed;
       }