From f5795a6092d6b4842e97bc67c11637d792961cb5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 10 Jun 2019 09:52:13 +0000 Subject: optionally support glibc malloc_info via SIGCONT If run with PERL_INLINE_DIRECTORY for Inline::C support along with INBOX_DEBUG=malloc_info, we can allow users to opt-in to compiling extra code to support the glibc malloc_info(3) function. We'll also add SIGCONT handler to dump the malloc_info(3) output to stderr on our daemons. --- lib/PublicInbox/Spawn.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib') diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index 66b916df..9210f111 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -149,6 +149,23 @@ int pi_fork_exec(int in, int out, int err, } VFORK_SPAWN +# TODO: we may support other mallocs through this parameter +if (($ENV{INBOX_DEBUG} // '') =~ /\bmalloc_info\b/) { + $vfork_spawn .= < + +int inbox_malloc_info(int options) +{ + int rc = malloc_info(options, stderr); + + return rc == 0 ? TRUE : FALSE; +} +MALLOC_DEBUG + + # dump malloc info to stderr on SIGCONT + $SIG{CONT} = sub { inbox_malloc_info(0) }; +} + my $inline_dir = $ENV{PERL_INLINE_DIRECTORY}; $vfork_spawn = undef unless defined $inline_dir && -d $inline_dir && -w _; if (defined $vfork_spawn) { -- cgit v1.2.3-24-ge0c7