]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cache: Fix loop on cache entries in "show cache"
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 23 Nov 2021 15:03:05 +0000 (16:03 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 23 Nov 2021 15:15:02 +0000 (16:15 +0100)
A regression was introduced in the commit da91842b6 ("BUG/MEDIUM: cache/cli:
make "show cache" thread-safe"). When cli_io_handler_show_cache() is called,
only one node is retrieved and is used to fill the output buffer in loop.
Once set, the "node" variable is never renewed. At the end, all nodes are
dumped but each one is duplicated several time into the output buffer.

This patch must be backported everywhere the above commit is. It means only
to 2.5 and 2.4.

src/cache.c

index 6ac23b27cedf4ca694f37cc54a6e6bf07877ed03..04e7327663c82b9c474558f8e341775f56f0b2b4 100644 (file)
@@ -2589,8 +2589,7 @@ static int cli_io_handler_show_cache(struct appctx *appctx)
                while (1) {
 
                        shctx_lock(shctx_ptr(cache));
-                       if (!node)
-                               node = eb32_lookup_ge(&cache->entries, next_key);
+                       node = eb32_lookup_ge(&cache->entries, next_key);
                        if (!node) {
                                shctx_unlock(shctx_ptr(cache));
                                appctx->ctx.cli.i0 = 0;