]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: htx: Remove htx_move_blk_before() function
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 29 Sep 2026 07:11:20 +0000 (09:11 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 29 Sep 2026 12:30:21 +0000 (14:30 +0200)
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.

doc/internals/api/htx-api.txt
include/haproxy/htx.h
src/htx.c

index 4559384da5e51e93a2c9c1dd32d092a7dae98b2f..4743ce287764f18bcc44fbadd716ca49f5514dd6 100644 (file)
@@ -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
index 6c281ac72f08d5324da328e3950c4b04b7700294..583a2ac7b92ce104468db17ded9e217ac5f9d7f0 100644 (file)
@@ -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);
index 12ce2d9644f92ef1d8d9b285e24777f4793be3d4..5583cd5a2ad2e1a644e03243f954a5a2fa505a06 100644 (file)
--- 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 <blk> just before the block <ref>. Both blocks must be in the
- * HTX message <htx> and <blk> must be placed after <ref>. 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 <pblk> 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 <src> to the HTX message <dst>. It returns 1 on
  * success and 0 on error.  All the message or nothing is copied. If an error
  * occurred, all blocks from <src> already appended to <dst> are truncated. On