diff options
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/smbcontrol.c | 49 |
1 files changed, 49 insertions, 0 deletions
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; /**************************************************************************** @@ -83,6 +85,34 @@ void debuglevel_function(int msg_type, pid_t src, void *buf, size_t len) } /**************************************************************************** +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 ****************************************************************************/ static BOOL send_message(char *dest, int msg_type, void *buf, int len) @@ -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); |