]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cache: Remove expired entry delete in "show cache" command
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Thu, 16 Nov 2023 16:38:16 +0000 (17:38 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 16 Nov 2023 18:35:10 +0000 (19:35 +0100)
The "show cache" CLI command iterates over all the entries of the cache
tree and it used this opportunity to remove expired entries from the
cache. This behavior was completely undocumented and does not seem that
necessary. By removing it we can take the cache lock in read mode only
which limits the impact on the other threads.

src/cache.c

index 7de5274988900803615ba906725c6b43aaa6d955..d311f8f448de9756828fd0ad955b48923bff2bd9 100644 (file)
@@ -2671,7 +2671,7 @@ static int cli_io_handler_show_cache(struct appctx *appctx)
 
                ctx->cache = cache;
 
-               cache_wrlock(cache);
+               cache_rdlock(cache);
 
                while (1) {
                        node = eb32_lookup_ge(&cache->entries, next_key);
@@ -2690,21 +2690,17 @@ static int cli_io_handler_show_cache(struct appctx *appctx)
                                chunk_appendf(&trash, " size:%u (%u blocks), refcount:%u, expire:%d\n",
                                              block_ptr(entry)->len, block_ptr(entry)->block_count,
                                              block_ptr(entry)->refcount, entry->expire - (int)date.tv_sec);
-                       } else {
-                               /* time to remove that one */
-                               delete_entry(entry);
-                               entry->eb.key = 0;
                        }
 
 
                        ctx->next_key = next_key;
 
                        if (applet_putchk(appctx, &trash) == -1) {
-                               cache_wrunlock(cache);
+                               cache_rdunlock(cache);
                                return 0;
                        }
                }
-               cache_wrunlock(cache);
+               cache_rdunlock(cache);
 
        }