mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
CLEANUP: pools: factor all malloc_trim() calls into trim_all_pools()
The code was slightly cleaned up by removing repeated occurrences of ifdefs and moving that into a single trim_all_pools() function.
This commit is contained in:
parent
c5d0fc9b9f
commit
ea3323f62c
27
src/pool.c
27
src/pool.c
@ -40,6 +40,21 @@ int mem_poison_byte = -1;
|
|||||||
static int mem_fail_rate = 0;
|
static int mem_fail_rate = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HA_HAVE_MALLOC_TRIM)
|
||||||
|
/* ask the allocator to trim memory pools */
|
||||||
|
static void trim_all_pools(void)
|
||||||
|
{
|
||||||
|
if (using_libc_allocator)
|
||||||
|
malloc_trim(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void trim_all_pools(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Try to find an existing shared pool with the same characteristics and
|
/* Try to find an existing shared pool with the same characteristics and
|
||||||
* returns it, otherwise creates this one. NULL is returned if no memory
|
* returns it, otherwise creates this one. NULL is returned if no memory
|
||||||
* is available for a new creation. Two flags are supported :
|
* is available for a new creation. Two flags are supported :
|
||||||
@ -275,9 +290,7 @@ void pool_flush(struct pool_head *pool)
|
|||||||
/* This function might ask the malloc library to trim its buffers. */
|
/* This function might ask the malloc library to trim its buffers. */
|
||||||
void pool_gc(struct pool_head *pool_ctx)
|
void pool_gc(struct pool_head *pool_ctx)
|
||||||
{
|
{
|
||||||
#if defined(HA_HAVE_MALLOC_TRIM)
|
trim_all_pools();
|
||||||
malloc_trim(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* CONFIG_HAP_NO_GLOBAL_POOLS */
|
#else /* CONFIG_HAP_NO_GLOBAL_POOLS */
|
||||||
@ -339,9 +352,7 @@ void pool_gc(struct pool_head *pool_ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HA_HAVE_MALLOC_TRIM)
|
trim_all_pools();
|
||||||
malloc_trim(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!isolated)
|
if (!isolated)
|
||||||
thread_release();
|
thread_release();
|
||||||
@ -358,9 +369,7 @@ void pool_flush(struct pool_head *pool)
|
|||||||
/* This function might ask the malloc library to trim its buffers. */
|
/* This function might ask the malloc library to trim its buffers. */
|
||||||
void pool_gc(struct pool_head *pool_ctx)
|
void pool_gc(struct pool_head *pool_ctx)
|
||||||
{
|
{
|
||||||
#if defined(HA_HAVE_MALLOC_TRIM)
|
trim_all_pools();
|
||||||
malloc_trim(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_HAP_POOLS */
|
#endif /* CONFIG_HAP_POOLS */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user