From: Christopher Faulet Date: Mon, 28 Sep 2026 17:10:48 +0000 (+0200) Subject: BUG/MINOR: htx: mark the message unordered when inserting headers or trailers X-Git-Url: https://git.kaiwu.me/web/http/static/%7B@url%7D?a=commitdiff_plain;h=94995ea250ea095e5f331887a5750cc4f2c962f5;p=haproxy.git BUG/MINOR: htx: mark the message unordered when inserting headers or trailers 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. --- diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h index 017c4d5df..0d6bd22c6 100644 --- a/include/haproxy/htx.h +++ b/include/haproxy/htx.h @@ -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