]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: add a debugging flag for memory poisonning option
authorWilly Tarreau <w@1wt.eu>
Wed, 23 Feb 2022 13:15:18 +0000 (14:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Feb 2022 16:11:33 +0000 (17:11 +0100)
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.

include/haproxy/pool-t.h
src/haproxy.c
src/pool.c

index 6f77bd985781af2b3803f4aa4487fbab5831b6dd..47fa34a5ddcc608b75b134e8d7ca2cffe621e3bd 100644 (file)
@@ -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 */
index 6350a6aa7bb8d96a12a818539ee3f2afe9fa6f2b..f2e417b267f548b46e2e18887f6b99c13c940d86 100644 (file)
@@ -1629,8 +1629,13 @@ static void init(int argc, char **argv)
                                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)
index b85a797a08fea937924f06b1944f372b9795542c..2cb37f345e081cc950b1fb352fa6459343e930b5 100644 (file)
@@ -34,7 +34,7 @@ THREAD_LOCAL size_t pool_cache_bytes = 0;                /* total cache size */
 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 @@ void *__pool_alloc(struct pool_head *pool, unsigned int flags)
        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;