MINOR: pools: switch DEBUG_DONT_SHARE_POOLS to runtime

This test used to appear at a single location in create_pool() to
enable a check on the pool name or unconditionally merge similarly
sized pools.

This patch introduces POOL_DBG_DONT_MERGE and conditions the test on
this new runtime flag, that is preset according to the aforementioned
debugging option.
This commit is contained in:
Willy Tarreau 2022-02-21 17:31:50 +01:00
parent 8d0273ed88
commit fd8b737e2c
2 changed files with 7 additions and 5 deletions

View File

@ -42,6 +42,7 @@
/* pool debugging flags */
#define POOL_DBG_FAIL_ALLOC 0x00000001 // randomly fail memory allocations
#define POOL_DBG_DONT_MERGE 0x00000002 // do not merge same-size pools
/* This is the head of a thread-local cache */

View File

@ -40,6 +40,9 @@ int mem_poison_byte __read_mostly = -1;
uint pool_debugging __read_mostly = /* set of POOL_DBG_* flags */
#ifdef DEBUG_FAIL_ALLOC
POOL_DBG_FAIL_ALLOC |
#endif
#ifdef DEBUG_DONT_SHARE_POOLS
POOL_DBG_DONT_MERGE |
#endif
0;
@ -214,11 +217,9 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
* we look for a shareable one or for the next position
* before which we will insert a new one.
*/
if ((flags & entry->flags & MEM_F_SHARED)
#ifdef DEBUG_DONT_SHARE_POOLS
&& strcmp(name, entry->name) == 0
#endif
) {
if ((flags & entry->flags & MEM_F_SHARED) &&
(!(pool_debugging & POOL_DBG_DONT_MERGE) ||
strcmp(name, entry->name) == 0)) {
/* we can share this one */
pool = entry;
DPRINTF(stderr, "Sharing %s with %s\n", name, pool->name);