mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-29 17:42:54 +00:00
MINOR: htx: Add the function htx_move_blk_before()
The function htx_add_data_before() was removed because it was buggy. The function htx_move_blk_before() may be used if necessary to do something equivalent, except it just moves blocks. It doesn't handle the adding.
This commit is contained in:
parent
d7884d3449
commit
86fcf6d6cd
@ -194,6 +194,7 @@ struct htx_blk *htx_add_endof(struct htx *htx, enum htx_blk_type type);
|
||||
struct htx_blk *htx_add_data_atonce(struct htx *htx, struct ist data);
|
||||
size_t htx_add_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_reqline_to_h1(const struct htx_sl *sl, struct buffer *chk);
|
||||
int htx_stline_to_h1(const struct htx_sl *sl, struct buffer *chk);
|
||||
|
23
src/htx.c
23
src/htx.c
@ -1037,6 +1037,29 @@ 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. */
|
||||
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)) {
|
||||
/* Swap .addr and .info fields */
|
||||
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;
|
||||
}
|
||||
|
||||
/* Appends the H1 representation of the request line block <blk> to the
|
||||
* chunk <chk>. It returns 1 if data are successfully appended, otherwise it
|
||||
* returns 0.
|
||||
|
Loading…
Reference in New Issue
Block a user