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);