From 20838bb9ed25d7a325831041f371c11731ff6283 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 11 Nov 2000 00:33:33 +0000 Subject: Merge of Herb's profiling code. Jeremy. (This used to be commit 3be056c71aa8e0a4ba70d397107199004bdb7d3f) --- source3/utils/smbcontrol.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source3/utils') diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index c059ccb6ec..a273f82151 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -29,6 +29,7 @@ static struct { {"force-election", MSG_FORCE_ELECTION}, {"ping", MSG_PING}, {"profile", MSG_PROFILE}, + {"profilelevel", MSG_REQ_PROFILELEVEL}, {"debuglevel", MSG_REQ_DEBUGLEVEL}, {"printer-notify", MSG_PRINTER_NOTIFY}, {NULL, -1} @@ -59,6 +60,7 @@ static int pong_count; static BOOL got_level; static BOOL pong_registered = False; static BOOL debuglevel_registered = False; +static BOOL profilelevel_registered = False; /**************************************************************************** @@ -82,6 +84,34 @@ void debuglevel_function(int msg_type, pid_t src, void *buf, size_t len) got_level = True; } +/**************************************************************************** +Prints out the current Profile level returned by MSG_PROFILELEVEL +****************************************************************************/ +void profilelevel_function(int msg_type, pid_t src, void *buf, size_t len) +{ + int level; + char *s; + memcpy(&level, buf, sizeof(int)); + + if (level) { + switch (level) { + case 1: + s = "off"; + break; + case 3: + s = "count only"; + break; + case 7: + s = "count and time"; + break; + } + printf("Profiling %s on PID %d\n",s,src); + } else { + printf("Profiling not available on PID %d\n",src); + } + got_level = True; +} + /**************************************************************************** send a message to a named destination ****************************************************************************/ @@ -176,6 +206,25 @@ static BOOL do_command(char *dest, char *msg_name, char *params) send_message(dest, MSG_FORCE_ELECTION, NULL, 0); break; + case MSG_REQ_PROFILELEVEL: + if (!profilelevel_registered) { + message_register(MSG_PROFILELEVEL, profilelevel_function); + profilelevel_registered = True; + } + got_level = False; + retval = send_message(dest, MSG_REQ_PROFILELEVEL, NULL, 0); + if (retval) { + timeout_start = time(NULL); + while (!got_level) { + message_dispatch(); + if ((time(NULL) - timeout_start) > MAX_WAIT) { + fprintf(stderr,"profilelevel timeout\n"); + break; + } + } + } + break; + case MSG_REQ_DEBUGLEVEL: if (!debuglevel_registered) { message_register(MSG_DEBUGLEVEL, debuglevel_function); -- cgit