From: Christopher Faulet Date: Thu, 23 May 2019 09:12:43 +0000 (+0200) Subject: MINOR: htx: don't rely on htx_find_blk() anymore in the function htx_truncate() X-Git-Tag: v2.0-dev5~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ced39006a2cce95cfe38ad77deba41eb90d45486;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/htx.c b/src/htx.c index 60bfc049b2..8ff6436336 100644 --- a/src/htx.c +++ b/src/htx.c @@ -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);