From 9ce93bc3be1dd5a5caecbb45966bc6b7b8e2c32b Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Wed, 21 May 2014 22:37:13 +0530 Subject: libglusterfs: Provide a way to disable mempool effects Problems: - Mempool comes in the way of debugging mem-leaks/corruptions because tools like valgrind can't detect mem-pools. - Accessing freed pointers may crash only when the mem-pool is completely exhausted. Solution: In DEBUG builds set mempool count to 0 irrespective of the pool size requested. This should help in debugging memory-leaks/corruptions. Change-Id: I7c6a2d696e330f12acff57ebdc589cc150e9ab79 BUG: 1100144 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/7835 Reviewed-by: Xavier Hernandez Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/mem-pool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index b233995b0b1..6207e995bc3 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -314,9 +314,10 @@ mem_pool_new_fn (unsigned long sizeof_type, INIT_LIST_HEAD (&mem_pool->global_list); mem_pool->padded_sizeof_type = padded_sizeof_type; - mem_pool->cold_count = count; mem_pool->real_sizeof_type = sizeof_type; +#ifndef DEBUG + mem_pool->cold_count = count; pool = GF_CALLOC (count, padded_sizeof_type, gf_common_mt_long); if (!pool) { GF_FREE (mem_pool->name); @@ -332,6 +333,7 @@ mem_pool_new_fn (unsigned long sizeof_type, mem_pool->pool = pool; mem_pool->pool_end = pool + (count * (padded_sizeof_type)); +#endif /* add this pool to the global list */ ctx = THIS->ctx; -- cgit