From: Willy Tarreau Date: Wed, 15 Sep 2021 08:41:24 +0000 (+0200) Subject: MINOR: pools: report it when malloc_trim() is enabled X-Git-Tag: v2.5-dev8~193 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=845b560f6a9abae68ba3f4e14e3c511aaf299f13;p=thirdparty%2Fhaproxy.git MINOR: pools: report it when malloc_trim() is enabled Since we can detect it at runtime now, it could help to have it mentioned in haproxy -vv. --- diff --git a/src/pool.c b/src/pool.c index f1c165d631..94bbb83557 100644 --- a/src/pool.c +++ b/src/pool.c @@ -68,6 +68,11 @@ static void detect_allocator(void) using_libc_allocator = !!memcmp(&mi1, &mi2, sizeof(mi1)); } + +static int is_trim_enabled(void) +{ + return using_libc_allocator; +} #else static void trim_all_pools(void) @@ -77,6 +82,11 @@ static void trim_all_pools(void) static void detect_allocator(void) { } + +static int is_trim_enabled(void) +{ + return 0; +} #endif /* Try to find an existing shared pool with the same characteristics and @@ -540,6 +550,17 @@ static void init_pools() INITCALL0(STG_PREPARE, init_pools); +/* Report in build options if trim is supported */ +static void pools_register_build_options(void) +{ + if (is_trim_enabled()) { + char *ptr = NULL; + memprintf(&ptr, "Support for malloc_trim() is enabled."); + hap_register_build_opts(ptr, 1); + } +} +INITCALL0(STG_REGISTER, pools_register_build_options); + /* register cli keywords */ static struct cli_kw_list cli_kws = {{ },{ { { "show", "pools", NULL }, "show pools : report information about the memory pools usage", NULL, cli_io_handler_dump_pools },