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.
This commit is contained in:
Christopher Faulet 2019-06-11 09:58:09 +02:00
parent 34a150ccf5
commit bda8397fba

View File

@ -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;