]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: enable the fault injector in all allocation modes
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Apr 2021 14:43:18 +0000 (16:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 Apr 2021 13:24:33 +0000 (15:24 +0200)
The mem_should_fail() call enabled by DEBUG_FAIL_ALLOC used to be placed
only in the no-cache version of the allocator. Now we can generalize it
to all modes and remove the exclusive test on CONFIG_HAP_NO_GLOBAL_POOLS.

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

index 4b185ef9ab724eff035d0a41587f2f57e7d9e86b..073fe3251a5aed9b066984df489317c8a9a72bbf 100644 (file)
@@ -46,7 +46,7 @@
  * case we disable global pools. The global pools may still be enforced
  * using CONFIG_HAP_GLOBAL_POOLS though.
  */
-#if defined(USE_THREAD) && defined(HA_HAVE_FAST_MALLOC) && defined(CONFIG_HAP_POOLS) && !defined(CONFIG_HAP_GLOBAL_POOLS)
+#if defined(USE_THREAD) && defined(HA_HAVE_FAST_MALLOC) && !defined(CONFIG_HAP_GLOBAL_POOLS)
 #define CONFIG_HAP_NO_GLOBAL_POOLS
 #endif
 
index b493a933e6c26cbad4a8d608bd0fc7a2da168fc6..59cc5083e960b0a571e356e5262e140be4e0844a 100644 (file)
@@ -156,6 +156,10 @@ void *__pool_refill_alloc(struct pool_head *pool, unsigned int avail)
        int limit = pool->limit;
        void *ptr = NULL;
 
+#ifdef DEBUG_FAIL_ALLOC
+       if (mem_should_fail(pool))
+               return NULL;
+#endif
        if (limit && allocated >= limit) {
                activity[tid].pool_fail++;
                return NULL;
@@ -218,6 +222,10 @@ void *__pool_refill_alloc(struct pool_head *pool, unsigned int avail)
        int limit = pool->limit;
        int allocated = pool->allocated, allocated_orig = allocated;
 
+#ifdef DEBUG_FAIL_ALLOC
+       if (mem_should_fail(pool))
+               return NULL;
+#endif
        /* stop point */
        avail += pool->used;