summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-11-11 00:33:33 +0000
committerJeremy Allison <jra@samba.org>2000-11-11 00:33:33 +0000
commit20838bb9ed25d7a325831041f371c11731ff6283 (patch)
treeef928af674aefabb2de152a1febbbc2afc52b8d1 /source3/utils
parentc97023b14c942f7261808159a0d192926239b704 (diff)
downloadsamba-20838bb9ed25d7a325831041f371c11731ff6283.tar.gz
samba-20838bb9ed25d7a325831041f371c11731ff6283.tar.bz2
samba-20838bb9ed25d7a325831041f371c11731ff6283.zip
Merge of Herb's profiling code.
Jeremy. (This used to be commit 3be056c71aa8e0a4ba70d397107199004bdb7d3f)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/smbcontrol.c49
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);