mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
BUG/MINOR: htx: Detect when tail_addr meet end_addr to maximize free rooms
When a block's payload is moved during an expansion or when the whole block is removed, the addresses of free spaces are updated accordingly. We must be careful to reset them when <tail_addr> becomes equal to <end_addr>. In this situation, we can maximize the free space between the blocks and their payload and set the other one to 0. It is also important to be sure to never have <end_addr> greater than <tail_addr>.
This commit is contained in:
parent
e4ab11bb88
commit
8c65486081
16
src/htx.c
16
src/htx.c
@ -249,11 +249,17 @@ static int htx_prepare_blk_expansion(struct htx *htx, struct htx_blk *blk, int32
|
|||||||
}
|
}
|
||||||
else if ((sz + delta) < headroom) {
|
else if ((sz + delta) < headroom) {
|
||||||
/* Move the block's payload into the headroom */
|
/* Move the block's payload into the headroom */
|
||||||
if (blk->addr == htx->end_addr)
|
|
||||||
htx->end_addr += sz;
|
|
||||||
blk->addr = htx->head_addr;
|
blk->addr = htx->head_addr;
|
||||||
htx->tail_addr -= sz;
|
htx->tail_addr -= sz;
|
||||||
htx->head_addr += sz + delta;
|
htx->head_addr += sz + delta;
|
||||||
|
if (blk->addr == htx->end_addr) {
|
||||||
|
if (htx->end_addr == htx->tail_addr) {
|
||||||
|
htx->tail_addr = htx->head_addr;
|
||||||
|
htx->head_addr = htx->end_addr = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
htx->end_addr += sz;
|
||||||
|
}
|
||||||
ret = 2;
|
ret = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,12 +374,14 @@ struct htx_blk *htx_remove_blk(struct htx *htx, struct htx_blk *blk)
|
|||||||
htx->tail_addr = addr;
|
htx->tail_addr = addr;
|
||||||
else if (addr+sz == htx->head_addr)
|
else if (addr+sz == htx->head_addr)
|
||||||
htx->head_addr = addr;
|
htx->head_addr = addr;
|
||||||
if (addr == htx->end_addr)
|
if (addr == htx->end_addr) {
|
||||||
htx->end_addr += sz;
|
|
||||||
if (htx->tail_addr == htx->end_addr) {
|
if (htx->tail_addr == htx->end_addr) {
|
||||||
htx->tail_addr = htx->head_addr;
|
htx->tail_addr = htx->head_addr;
|
||||||
htx->head_addr = htx->end_addr = 0;
|
htx->head_addr = htx->end_addr = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
htx->end_addr += sz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BUG_ON((int32_t)htx->tail_addr < 0);
|
BUG_ON((int32_t)htx->tail_addr < 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user