From fd8b737e2c29a886366808258234887fd10e50a5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 21 Feb 2022 17:31:50 +0100 Subject: [PATCH] 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. --- include/haproxy/pool-t.h | 1 + src/pool.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/haproxy/pool-t.h b/include/haproxy/pool-t.h index 8180bfb15..37980c629 100644 --- a/include/haproxy/pool-t.h +++ b/include/haproxy/pool-t.h @@ -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 */ diff --git a/src/pool.c b/src/pool.c index 3c85b08ee..7f9c3df5a 100644 --- a/src/pool.c +++ b/src/pool.c @@ -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);