]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: report it when malloc_trim() is enabled
authorWilly Tarreau <w@1wt.eu>
Wed, 15 Sep 2021 08:41:24 +0000 (10:41 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 15 Sep 2021 08:41:24 +0000 (10:41 +0200)
Since we can detect it at runtime now, it could help to have it mentioned
in haproxy -vv.

src/pool.c

index f1c165d631d7b7675d6735f8cd97f44bc6f10b4a..94bbb8355769453e0e31526dbf7c9b45fd5520df 100644 (file)
@@ -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 },