]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cache: Dump secondary entries in "show cache"
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Fri, 27 Nov 2020 14:48:40 +0000 (15:48 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 10 Dec 2020 14:59:49 +0000 (15:59 +0100)
The duplicated entries (in case of vary) were not taken into account by
the "show cache" command. They are now dumped too.
A new "vary" column is added to the output. It contains the complete
seocndary key (in hex format).

doc/management.txt
src/cache.c

index 5e6262c30ac7711bb7ebf463fd8f81fc940a8729..b1ca95185b22c0131823c90afcd3f66bca4c7199 100644 (file)
@@ -2021,15 +2021,16 @@ show cache
   3. pointer to the mmap area (shctx)
   4. number of blocks available for reuse in the shctx
 
-  0x7f6ac6c5b4cc hash:286881868 size:39114 (39 blocks), refcount:9, expire:237
-           1               2            3        4            5           6
+  0x7f6ac6c5b4cc hash:286881868 vary:0x0011223344556677 size:39114 (39 blocks), refcount:9, expire:237
+           1               2               3                    4        5            6           7
 
   1. pointer to the cache entry
   2. first 32 bits of the hash
-  3. size of the object in bytes
-  4. number of blocks used for the object
-  5. number of transactions using the entry
-  6. expiration time, can be negative if already expired
+  3. secondary hash of the entry in case of vary
+  4. size of the object in bytes
+  5. number of blocks used for the object
+  6. number of transactions using the entry
+  7. expiration time, can be negative if already expired
 
 show env [<name>]
   Dump one or all environment variables known by the process. Without any
index df6bd3352e221f8bbd247b902c3ae36e55524d13..bc9bb9873b6b8636b4317e714574085aa7973283 100644 (file)
@@ -2135,6 +2135,7 @@ static int cli_io_handler_show_cache(struct appctx *appctx)
                struct eb32_node *node = NULL;
                unsigned int next_key;
                struct cache_entry *entry;
+               unsigned int i;
 
                next_key = appctx->ctx.cli.i0;
                if (!next_key) {
@@ -2150,7 +2151,8 @@ static int cli_io_handler_show_cache(struct appctx *appctx)
                while (1) {
 
                        shctx_lock(shctx_ptr(cache));
-                       node = eb32_lookup_ge(&cache->entries, next_key);
+                       if (!node || (node = eb32_next_dup(node)) == NULL)
+                               node = eb32_lookup_ge(&cache->entries, next_key);
                        if (!node) {
                                shctx_unlock(shctx_ptr(cache));
                                appctx->ctx.cli.i0 = 0;
@@ -2158,7 +2160,10 @@ static int cli_io_handler_show_cache(struct appctx *appctx)
                        }
 
                        entry = container_of(node, struct cache_entry, eb);
-                       chunk_printf(&trash, "%p hash:%u size:%u (%u blocks), refcount:%u, expire:%d\n", entry, read_u32(entry->hash), block_ptr(entry)->len, block_ptr(entry)->block_count, block_ptr(entry)->refcount, entry->expire - (int)now.tv_sec);
+                       chunk_printf(&trash, "%p hash:%u vary:0x", entry, read_u32(entry->hash));
+                       for (i = 0; i < HTTP_CACHE_SEC_KEY_LEN; ++i)
+                               chunk_appendf(&trash, "%02x", (unsigned char)entry->secondary_key[i]);
+                       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)now.tv_sec);
 
                        next_key = node->key + 1;
                        appctx->ctx.cli.i0 = next_key;