]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: htx: mark the message unordered when inserting headers or trailers
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 28 Sep 2026 17:10:48 +0000 (19:10 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 12:41:06 +0000 (13:41 +0100)
Before commit 0a9ecebda ("MEDIUM: htx: Insert headers and trailers
before corresponding end-of block") in 3.5-dev8, htx_add_header() and
htx_add_trailer() set HTX_FL_UNORDERED when the block was added after
the end-of-headers or end-of-trailers block, since its payload is then
located after the ones of the following blocks. The new code now moves
the block before the end-of block, but doesn't set this flag anymore
while the payloads are still unordered. The flag is used to decide to
defragment the message in the body sample fetches (req.body,
res.body, req.body_param...), so that DATA blocks may be merged and the
body retrieved without copy. Without it, this optimization is skipped. This
is not a correctness issue, but a performance regression.

Let's set the flag again when the new block is moved.

This patch should be backported to 3.5.

include/haproxy/htx.h

index 017c4d5df55ca66f34ea13cb0631f6e26bbc9ecb..0d6bd22c6c1b188cfbe63f810460c2533c5daa8c 100644 (file)
@@ -593,6 +593,9 @@ static inline struct htx_blk *htx_add_header(struct htx *htx, const struct ist n
                blk->addr ^= prevblk->addr; prevblk->addr ^= blk->addr; blk->addr ^= prevblk->addr;
                blk->info ^= prevblk->info; prevblk->info ^= blk->info; blk->info ^= prevblk->info;
                blk = prevblk;
+
+               /* the payloads are not in the blocks order anymore */
+               htx->flags |= HTX_FL_UNORDERED;
        }
 
        /* The new block was moved before any block of a greater type, and the
@@ -637,6 +640,9 @@ static inline struct htx_blk *htx_add_trailer(struct htx *htx, const struct ist
                blk->addr ^= prevblk->addr; prevblk->addr ^= blk->addr; blk->addr ^= prevblk->addr;
                blk->info ^= prevblk->info; prevblk->info ^= blk->info; blk->info ^= prevblk->info;
                blk = prevblk;
+
+               /* the payloads are not in the blocks order anymore */
+               htx->flags |= HTX_FL_UNORDERED;
        }
 
        /* The new block was moved before any block of a greater type, and the