From: Christopher Faulet Date: Tue, 11 Jun 2019 07:58:09 +0000 (+0200) Subject: BUG/MINOR: cache/htx: Fix the counting of data already sent by the cache applet X-Git-Tag: v2.0-dev7~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bda8397fba027eaee2c46d566a7e85343dc2de02;p=thirdparty%2Fhaproxy.git BUG/MINOR: cache/htx: Fix the counting of data already sent by the cache applet Since the commit 8f3c256f7 ("MEDIUM: cache/htx: Always store info about HTX blocks in the cache"), it is possible to read info about a data block without sending anything. It is possible because we rely on the function htx_add_data(), which will try to add data without any defragmentation. In such case, info about the data block are skipped but don't count in data sent. No need to backport this patch, expect if the commit 8f3c256f7 is backported too. --- diff --git a/src/cache.c b/src/cache.c index d63cc790bd..3504fbaa46 100644 --- a/src/cache.c +++ b/src/cache.c @@ -898,7 +898,6 @@ static unsigned int htx_cache_dump_blk(struct appctx *appctx, struct htx *htx, e offset = 0; } } - appctx->ctx.cache.offset = offset; appctx->ctx.cache.next = shblk; appctx->ctx.cache.sent += total; @@ -918,13 +917,16 @@ static unsigned int htx_cache_dump_data_blk(struct appctx *appctx, struct htx *h if (!max) return 0; - total = 0; rem_data = 0; - blksz = ((appctx->ctx.cache.rem_data) - ? appctx->ctx.cache.rem_data - : (info & 0xfffffff)); - if (blksz > max) { + if (appctx->ctx.cache.rem_data) { + blksz = appctx->ctx.cache.rem_data; total = 0; + } + else { + blksz = (info & 0xfffffff); + total = 4; + } + if (blksz > max) { rem_data = blksz - max; blksz = max; } @@ -945,9 +947,6 @@ static unsigned int htx_cache_dump_data_blk(struct appctx *appctx, struct htx *h } } - if (total && !appctx->ctx.cache.rem_data) - total += 4; - appctx->ctx.cache.offset = offset; appctx->ctx.cache.next = shblk; appctx->ctx.cache.sent += total;