MINOR: htx: don't rely on htx_find_blk() anymore in the function htx_truncate()

the function htx_find_blk() is used by only one function, htx_truncate(). So
because this function does nothing very smart, we don't use it anymore. It will
be removed by another commit.
This commit is contained in:
Christopher Faulet 2019-05-23 11:12:43 +02:00 committed by Willy Tarreau
parent 0f6d6a9ab6
commit ced39006a2

View File

@ -284,15 +284,20 @@ struct htx_blk *htx_remove_blk(struct htx *htx, struct htx_blk *blk)
void htx_truncate(struct htx *htx, uint32_t offset)
{
struct htx_blk *blk;
struct htx_ret htxret;
htxret = htx_find_blk(htx, offset);
blk = htxret.blk;
if (blk && htxret.ret) {
for (blk = htx_get_head_blk(htx); blk && offset; blk = htx_get_next_blk(htx, blk)) {
uint32_t sz = htx_get_blksz(blk);
enum htx_blk_type type = htx_get_blk_type(blk);
htx_set_blk_value_len(blk, sz - htxret.ret);
blk = htx_get_next_blk(htx, blk);
if (offset >= sz) {
offset -= sz;
continue;
}
if (type == HTX_BLK_DATA || type == HTX_BLK_TLR) {
htx_set_blk_value_len(blk, offset);
htx->data -= (sz - offset);
}
offset = 0;
}
while (blk)
blk = htx_remove_blk(htx, blk);