From: Christopher Faulet Date: Tue, 29 Sep 2026 07:11:20 +0000 (+0200) Subject: MINOR: htx: Remove htx_move_blk_before() function X-Git-Tag: v3.5-dev8~99 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=ab6ce5c7d1a7802ef1a938c706717d8d54af59d5;p=haproxy.git MINOR: htx: Remove htx_move_blk_before() function This function is used and ambiguous. Indeed, it is not clear how to used it. The caller is responsible to know what he does. But at the end, it is a not so easy. Especially about the way the EOM flag is handled. So to avoid bugs, it is safer to remove the function. --- diff --git a/doc/internals/api/htx-api.txt b/doc/internals/api/htx-api.txt index 4559384da..4743ce287 100644 --- a/doc/internals/api/htx-api.txt +++ b/doc/internals/api/htx-api.txt @@ -440,12 +440,6 @@ help (others could be added) : remains on the last block of the message. This function is dedicated to regular DATA blocks, it must not be used for tunneled data. - - htx_move_blk_before() moves a specific block just before another one. Both - blocks must already be in the HTX message and the block to move must - always be placed after the "pivot". The flag marking the end of the - message, if any, is kept on the last block of the message. However it - remains the caller responsibility to take care the result is still valid. - Once added, there are three functions to update the block's payload : - htx_replace_stline() updates a start-line. The HTX block must be passed as diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h index 6c281ac72..583a2ac7b 100644 --- a/include/haproxy/htx.h +++ b/include/haproxy/htx.h @@ -56,7 +56,6 @@ size_t htx_add_data_type(struct htx *htx, const struct ist data, enum htx_blk_ty size_t htx_add_data(struct htx *htx, const struct ist data); size_t htx_add_raw_data(struct htx *htx, const struct ist data); struct htx_blk *htx_add_last_data(struct htx *htx, struct ist data); -void htx_move_blk_before(struct htx *htx, struct htx_blk **blk, struct htx_blk **ref); int htx_append_msg(struct htx *dst, const struct htx *src); struct buffer *htx_move_to_small_buffer(struct buffer *dst, struct buffer *src); struct buffer *htx_move_to_large_buffer(struct buffer *dst, struct buffer *src); diff --git a/src/htx.c b/src/htx.c index 12ce2d964..5583cd5a2 100644 --- a/src/htx.c +++ b/src/htx.c @@ -1327,41 +1327,6 @@ struct htx_blk *htx_add_last_data(struct htx *htx, struct ist data) return blk; } -/* Moves the block just before the block . Both blocks must be in the - * HTX message and must be placed after . pointer to these - * blocks are updated to remain valid after the move. - * - * It is the caller responsibility to take care the result remains valid. - */ -void htx_move_blk_before(struct htx *htx, struct htx_blk **blk, struct htx_blk **ref) -{ - struct htx_blk *cblk, *pblk; - - cblk = *blk; - for (pblk = htx_get_prev_blk(htx, cblk); pblk; pblk = htx_get_prev_blk(htx, pblk)) { - htx->flags |= HTX_FL_UNORDERED; - - /* transfer EOM to before swapping blocs */ - if (cblk->flags & HTX_BLK_FL_EOM) { - pblk->flags |= HTX_BLK_FL_EOM; - cblk->flags &= ~HTX_BLK_FL_EOM; - } - - /* Swap .flags, .addr and .info fields */ - cblk->flags ^= pblk->flags; pblk->flags ^= cblk->flags; cblk->flags ^= pblk->flags; - cblk->addr ^= pblk->addr; pblk->addr ^= cblk->addr; cblk->addr ^= pblk->addr; - cblk->info ^= pblk->info; pblk->info ^= cblk->info; cblk->info ^= pblk->info; - - if (cblk->addr == pblk->addr) - cblk->addr += htx_get_blksz(pblk); - if (pblk == *ref) - break; - cblk = pblk; - } - *blk = cblk; - *ref = pblk; -} - /* Append the HTX message to the HTX message . It returns 1 on * success and 0 on error. All the message or nothing is copied. If an error * occurred, all blocks from already appended to are truncated. On