]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINPR: htx: Get large chunk if necessary to perform a defrag
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 11 Feb 2026 16:46:00 +0000 (17:46 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 18 Feb 2026 12:26:21 +0000 (13:26 +0100)
Function performing defragmentation of an HTX message was updated to get a
chunk accordingly to the HTX message size.

src/htx.c

index 3ed18b9a86fa7a4350832dfd3f15ed6ee6c4a83c..5b64a8db41370275001d64cbc3353ca54ed04466 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -39,8 +39,8 @@ static inline __attribute__((always_inline)) void htx_memcpy(void *dst, void *sr
  */
 struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk, uint32_t blkinfo)
 {
-       struct buffer *chunk;
-       struct htx *tmp;
+       struct buffer *chunk = get_trash_chunk_sz(htx->size+sizeof(struct htx));
+       struct htx *tmp = htxbuf(chunk);
        struct htx_blk *newblk, *oldblk;
        enum htx_blk_type type;
        uint32_t new, old, blkpos;
@@ -49,9 +49,6 @@ struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk, uint32_t blkinf
        if (htx->head == -1)
                return NULL;
 
-       chunk = alloc_trash_chunk();
-       tmp = htxbuf(chunk);
-
        blkpos = -1;
 
        new  = 0;
@@ -103,7 +100,6 @@ struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk, uint32_t blkinf
        htx->flags &= ~(HTX_FL_FRAGMENTED|HTX_FL_UNORDERED);
        htx_memcpy((void *)htx->blocks, (void *)tmp->blocks, htx->size);
 
-       free_trash_chunk(chunk);
        return ((blkpos == -1) ? NULL : htx_get_blk(htx, blkpos));
 }