MINOR: pools: add a debugging flag for memory poisonning option
Now -dM will set POOL_DBG_POISON for consistency with the rest of the
pool debugging options. As such now we only check for the new flag,
which allows the default value to be preset.
diff --git a/include/haproxy/pool-t.h b/include/haproxy/pool-t.h
index 6f77bd9..47fa34a 100644
--- a/include/haproxy/pool-t.h
+++ b/include/haproxy/pool-t.h
@@ -49,6 +49,7 @@
#define POOL_DBG_NO_CACHE 0x00000020 // disable thread-local pool caches
#define POOL_DBG_CALLER 0x00000040 // trace last caller's location
#define POOL_DBG_TAG 0x00000080 // place a tag at the end of the area
+#define POOL_DBG_POISON 0x00000100 // poison memory area on pool_alloc()
/* This is the head of a thread-local cache */
diff --git a/src/haproxy.c b/src/haproxy.c
index 6350a6a..f2e417b 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1629,8 +1629,13 @@
arg_mode |= MODE_DIAG;
else if (*flag == 'd' && flag[1] == 'W')
arg_mode |= MODE_ZERO_WARNING;
- else if (*flag == 'd' && flag[1] == 'M')
+ else if (*flag == 'd' && flag[1] == 'M') {
mem_poison_byte = flag[2] ? strtol(flag + 2, NULL, 0) : 'P';
+ if (mem_poison_byte >= 0)
+ pool_debugging |= POOL_DBG_POISON;
+ else
+ pool_debugging &= ~POOL_DBG_POISON;
+ }
else if (*flag == 'd' && flag[1] == 'r')
global.tune.options |= GTUNE_RESOLVE_DONTFAIL;
#if defined(HA_HAVE_DUMP_LIBS)
diff --git a/src/pool.c b/src/pool.c
index b85a797..2cb37f3 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -34,7 +34,7 @@
THREAD_LOCAL size_t pool_cache_count = 0; /* #cache objects */
static struct list pools __read_mostly = LIST_HEAD_INIT(pools);
-int mem_poison_byte __read_mostly = -1;
+int mem_poison_byte __read_mostly = 'P';
uint pool_debugging __read_mostly = /* set of POOL_DBG_* flags */
#ifdef DEBUG_FAIL_ALLOC
POOL_DBG_FAIL_ALLOC |
@@ -700,7 +700,7 @@
if (likely(p)) {
if (unlikely(flags & POOL_F_MUST_ZERO))
memset(p, 0, pool->size);
- else if (unlikely(!(flags & POOL_F_NO_POISON) && mem_poison_byte >= 0))
+ else if (unlikely(!(flags & POOL_F_NO_POISON) && (pool_debugging & POOL_DBG_POISON)))
memset(p, mem_poison_byte, pool->size);
}
return p;