summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/messages.h2
-rw-r--r--source3/lib/messages.c1
-rw-r--r--source3/profile/profile.c17
-rw-r--r--source3/utils/smbcontrol.c49
4 files changed, 69 insertions, 0 deletions
diff --git a/source3/include/messages.h b/source3/include/messages.h
index b5e4f62593..513f7b24a1 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -29,6 +29,8 @@
#define MSG_PROFILE 4
#define MSG_REQ_DEBUGLEVEL 5
#define MSG_DEBUGLEVEL 6
+#define MSG_REQ_PROFILELEVEL 7
+#define MSG_PROFILELEVEL 8
/* nmbd messages */
#define MSG_FORCE_ELECTION 1001
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 1cc6700ea9..126ca768b7 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -334,6 +334,7 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void
memcpy(&crec, dbuf.dptr, sizeof(crec));
+ if (crec.cnum == -1) return 0;
message_send_pid(crec.pid, msg_all.msg_type, msg_all.buf, msg_all.len);
return 0;
}
diff --git a/source3/profile/profile.c b/source3/profile/profile.c
index f1d2310ce1..80584adfa2 100644
--- a/source3/profile/profile.c
+++ b/source3/profile/profile.c
@@ -73,6 +73,22 @@ void profile_message(int msg_type, pid_t src, void *buf, size_t len)
}
}
+/****************************************************************************
+receive a request profile level message
+****************************************************************************/
+void reqprofile_message(int msg_type, pid_t src, void *buf, size_t len)
+{
+ int level;
+
+#ifdef WITH_PROFILE
+ level = 1 + (do_profile_flag?2:0) + (do_profile_times?4:0);
+#else
+ level = 0;
+#endif
+ DEBUG(1,("INFO: Received REQ_PROFILELEVEL message from PID %d\n",src));
+ message_send_pid(src, MSG_PROFILELEVEL, &level, sizeof(int));
+}
+
/*******************************************************************
open the profiling shared memory area
******************************************************************/
@@ -140,6 +156,7 @@ BOOL profile_setup(BOOL rdonly)
profile_p = &profile_h->stats;
message_register(MSG_PROFILE, profile_message);
+ message_register(MSG_REQ_PROFILELEVEL, reqprofile_message);
return True;
}
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);