From ef8bd7c4f7ae8192ea05db070962ecf0ff3615f3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 20 Dec 2002 20:21:31 +0000 Subject: Forward port the change to talloc_init() to make all talloc contexts named. Ensure we can query them. Jeremy. (This used to be commit 09a218a9f6fb0bd922940467bf8500eb4f1bcf84) --- source3/utils/smbcontrol.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'source3/utils/smbcontrol.c') diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 72ac2dd095..f4d197147f 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -43,6 +43,7 @@ static struct { {"dmalloc-log-changed", MSG_REQ_DMALLOC_LOG_CHANGED }, {"shutdown", MSG_SHUTDOWN }, {"drvupgrade", MSG_PRINTER_DRVUPGRADE}, + {"tallocdump", MSG_REQ_TALLOC_USAGE}, {NULL, -1} }; @@ -75,8 +76,10 @@ static void usage(BOOL doexit) static int pong_count; static BOOL got_level; +static BOOL got_pool; static BOOL pong_registered = False; static BOOL debuglevel_registered = False; +static BOOL poolusage_registered = False; static BOOL profilelevel_registered = False; @@ -108,6 +111,22 @@ void pong_function(int msg_type, pid_t src, void *buf, size_t len) printf("PONG from PID %u\n",(unsigned int)src); } +/**************************************************************************** + Prints out the current talloc list. +****************************************************************************/ +void tallocdump_function(int msg_type, pid_t src, void *buf, size_t len) +{ + char *info = (char *)buf; + + printf("Current talloc contexts for process %u\n", (unsigned int)src ); + if (len == 0) + printf("None returned\n"); + else + printf(info); + printf("\n"); + got_pool = True; +} + /**************************************************************************** Prints out the current Debug level returned by MSG_DEBUGLEVEL ****************************************************************************/ @@ -347,6 +366,25 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params) } break; + case MSG_REQ_TALLOC_USAGE: + if (!poolusage_registered) { + message_register(MSG_TALLOC_USAGE, tallocdump_function); + poolusage_registered = True; + } + got_pool = False; + retval = send_message(dest, MSG_REQ_TALLOC_USAGE, NULL, 0, True); + if (retval) { + timeout_start = time(NULL); + while (!got_pool) { + message_dispatch(); + if ((time(NULL) - timeout_start) > MAX_WAIT) { + fprintf(stderr,"tallocdump timeout\n"); + break; + } + } + } + break; + case MSG_REQ_DEBUGLEVEL: if (!debuglevel_registered) { message_register(MSG_DEBUGLEVEL, debuglevel_function); -- cgit