]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: debug: keep runtime limits in postmortem
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Sun, 14 Jul 2024 14:58:02 +0000 (16:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 16 Jul 2024 12:04:41 +0000 (14:04 +0200)
It's usefull to keep runtime limits (fd and RAM) in postmortem and show them in
debug_parse_cli_show_dev(). Runtime limits are fed in feed_post_mortem_late(),
as we are sure that at this moment that all configuration was parsed and
all applied limits were alredy adjusted.

src/debug.c

index 683f36e27badfee58287ec79ccadf89db56687a4..b24344fc8f5b7c724a5beac327e8136e1325b29f 100644 (file)
@@ -131,6 +131,8 @@ struct post_mortem {
 #endif
                struct rlimit boot_lim_fd;  // RLIMIT_NOFILE at startup
                struct rlimit boot_lim_ram; // RLIMIT_DATA at startup
+               struct rlimit run_lim_fd;  // RLIMIT_NOFILE just before enter in polling loop
+               struct rlimit run_lim_ram; // RLIMIT_DATA just before enter in polling loop
                char **argv;
 
 #if defined(USE_THREAD)
@@ -616,6 +618,16 @@ static int debug_parse_cli_show_dev(char **args, char *payload, struct appctx *a
        chunk_appendf(&trash, "  \tram limit (hard): %s\n",
                      LIM2A(normalize_rlim((ulong)post_mortem.process.boot_lim_ram.rlim_max), "unlimited"));
 
+       chunk_appendf(&trash, "  runtime limits:\n");
+       chunk_appendf(&trash, "  \tfd limit (soft): %s\n",
+                     LIM2A(normalize_rlim((ulong)post_mortem.process.run_lim_fd.rlim_cur), "unlimited"));
+       chunk_appendf(&trash, "  \tfd limit (hard): %s\n",
+                     LIM2A(normalize_rlim((ulong)post_mortem.process.run_lim_fd.rlim_max), "unlimited"));
+       chunk_appendf(&trash, "  \tram limit (soft): %s\n",
+                     LIM2A(normalize_rlim((ulong)post_mortem.process.run_lim_ram.rlim_cur), "unlimited"));
+       chunk_appendf(&trash, "  \tram limit (hard): %s\n",
+                     LIM2A(normalize_rlim((ulong)post_mortem.process.run_lim_ram.rlim_max), "unlimited"));
+
        return cli_msg(appctx, LOG_INFO, trash.area);
 }
 
@@ -2444,6 +2456,8 @@ static int feed_post_mortem_late()
                post_mortem.process.caps.err_run = errno;
        }
 #endif
+       getrlimit(RLIMIT_NOFILE, &post_mortem.process.run_lim_fd);
+       getrlimit(RLIMIT_DATA, &post_mortem.process.run_lim_ram);
 
        return 1;
 }