summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerb Lewis <herb@samba.org>2000-10-06 21:32:57 +0000
committerHerb Lewis <herb@samba.org>2000-10-06 21:32:57 +0000
commit073e336aaa518f6a8a6cdabf10e6a7d23cfe77bd (patch)
tree72cbd52d531ebb8ea092c000e57f4f6f9490abad
parent4f5d2f9649a4d9b5c983148029c068deb5eee186 (diff)
downloadsamba-073e336aaa518f6a8a6cdabf10e6a7d23cfe77bd.tar.gz
samba-073e336aaa518f6a8a6cdabf10e6a7d23cfe77bd.tar.xz
samba-073e336aaa518f6a8a6cdabf10e6a7d23cfe77bd.zip
proto.h rebuild proto.h
messages.h add new message types profile.h change profile start and end macros to allow times to not be gathered messages.c add message handling for returning current debug level profile.c add a new flag to allow time profiling to to turned off default flags to off now they can be set by smbcontrol add message handlinf for setting profile level smbcontrol.c add printout in pong function so you can see replies add new set profile level and get debug level messages add flags so we don't register callbacks more than once when in interactive mode and reset pong count each time
-rw-r--r--source/include/messages.h9
-rw-r--r--source/include/profile.h9
-rw-r--r--source/include/proto.h2
-rw-r--r--source/lib/messages.c12
-rw-r--r--source/profile/profile.c28
-rw-r--r--source/utils/smbcontrol.c61
6 files changed, 112 insertions, 9 deletions
diff --git a/source/include/messages.h b/source/include/messages.h
index 4ddb82ee305..b5e4f625931 100644
--- a/source/include/messages.h
+++ b/source/include/messages.h
@@ -23,9 +23,12 @@
#define _MESSAGES_H_
/* general messages */
-#define MSG_DEBUG 1
-#define MSG_PING 2
-#define MSG_PONG 3
+#define MSG_DEBUG 1
+#define MSG_PING 2
+#define MSG_PONG 3
+#define MSG_PROFILE 4
+#define MSG_REQ_DEBUGLEVEL 5
+#define MSG_DEBUGLEVEL 6
/* nmbd messages */
#define MSG_FORCE_ELECTION 1001
diff --git a/source/include/profile.h b/source/include/profile.h
index d18f598021e..c196a63c62f 100644
--- a/source/include/profile.h
+++ b/source/include/profile.h
@@ -319,6 +319,7 @@ extern struct profile_struct *profile_p;
extern struct timeval profile_starttime;
extern struct timeval profile_endtime;
extern BOOL do_profile_flag;
+extern BOOL do_profile_times;
/* these are helper macros - do not call them directly in the code
* use the DO_PROFILE_* START_PROFILE and END_PROFILE ones
@@ -349,17 +350,19 @@ extern BOOL do_profile_flag;
}
#define START_PROFILE(x) \
if (do_profile_flag) { \
- GetTimeOfDay(&profile_starttime); \
+ if (do_profile_times) \
+ GetTimeOfDay(&profile_starttime); \
INC_PROFILE_COUNT(x##_count); \
}
#define START_PROFILE_BYTES(x,n) \
if (do_profile_flag) { \
- GetTimeOfDay(&profile_starttime); \
+ if (do_profile_times) \
+ GetTimeOfDay(&profile_starttime); \
INC_PROFILE_COUNT(x##_count); \
ADD_PROFILE_COUNT(x##_bytes,n); \
}
#define END_PROFILE(x) \
- if (do_profile_flag) { \
+ if (do_profile_times) { \
GetTimeOfDay(&profile_endtime); \
ADD_PROFILE_COUNT(x##_time,PROFILE_TIME); \
}
diff --git a/source/include/proto.h b/source/include/proto.h
index 3280745443c..b52c07ac192 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -151,6 +151,7 @@ void mdfour(unsigned char *out, unsigned char *in, int n);
/*The following definitions come from lib/messages.c */
void ping_message(int msg_type, pid_t src, void *buf, size_t len);
+void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len);
BOOL message_init(void);
BOOL message_send_pid(pid_t pid, int msg_type, void *buf, size_t len);
void message_dispatch(void);
@@ -1783,6 +1784,7 @@ BOOL print_queue_purge(struct current_user *user, int snum, int *errcode);
/*The following definitions come from profile/profile.c */
+void profile_message(int msg_type, pid_t src, void *buf, size_t len);
BOOL profile_setup(BOOL rdonly);
/*The following definitions come from rpc_client/cli_connect.c */
diff --git a/source/lib/messages.c b/source/lib/messages.c
index 258610f409a..1b225b1ed30 100644
--- a/source/lib/messages.c
+++ b/source/lib/messages.c
@@ -74,6 +74,17 @@ void ping_message(int msg_type, pid_t src, void *buf, size_t len)
}
/****************************************************************************
+return current debug level
+****************************************************************************/
+void debuglevel_message(int msg_type, pid_t src, void *buf, size_t len)
+{
+ int level;
+
+ level = DEBUGLEVEL;
+ message_send_pid(src, MSG_DEBUGLEVEL, &level, sizeof(int));
+}
+
+/****************************************************************************
Initialise the messaging functions.
****************************************************************************/
BOOL message_init(void)
@@ -92,6 +103,7 @@ BOOL message_init(void)
CatchSignal(SIGUSR1, SIGNAL_CAST sig_usr1);
message_register(MSG_PING, ping_message);
+ message_register(MSG_REQ_DEBUGLEVEL, debuglevel_message);
return True;
}
diff --git a/source/profile/profile.c b/source/profile/profile.c
index 5b8b280c293..87f5e2c9b22 100644
--- a/source/profile/profile.c
+++ b/source/profile/profile.c
@@ -34,10 +34,36 @@ static BOOL read_only;
struct profile_struct *profile_p;
BOOL do_profile_flag = False;
+BOOL do_profile_times = False;
struct timeval profile_starttime;
struct timeval profile_endtime;
+/****************************************************************************
+receive a set profile level message
+****************************************************************************/
+void profile_message(int msg_type, pid_t src, void *buf, size_t len)
+{
+ int level;
+
+ memcpy(&level, buf, sizeof(int));
+ switch (level) {
+ case 0:
+ do_profile_flag = False;
+ do_profile_times = False;
+ break;
+ case 1:
+ do_profile_flag = True;
+ do_profile_times = False;
+ break;
+ case 2:
+ do_profile_flag = True;
+ do_profile_times = True;
+ break;
+ }
+ DEBUG(1,("Profile level set to %d from pid %d\n", level, (int)src));
+}
+
/*******************************************************************
open the profiling shared memory area
******************************************************************/
@@ -103,7 +129,7 @@ BOOL profile_setup(BOOL rdonly)
DEBUG(3,("Initialised profile area\n"));
}
- do_profile_flag = True; /* temp for now */
+ message_register(MSG_PROFILE, profile_message);
return True;
}
diff --git a/source/utils/smbcontrol.c b/source/utils/smbcontrol.c
index cedb13620d5..306f7ee269c 100644
--- a/source/utils/smbcontrol.c
+++ b/source/utils/smbcontrol.c
@@ -30,6 +30,8 @@ static struct {
{"debug", MSG_DEBUG},
{"force-election", MSG_FORCE_ELECTION},
{"ping", MSG_PING},
+ {"profile", MSG_PROFILE},
+ {"debuglevel", MSG_REQ_DEBUGLEVEL},
{NULL, -1}
};
@@ -44,12 +46,17 @@ static void usage(BOOL doexit)
}
printf("\t<destination> is one of \"nmbd\", \"smbd\" or a process ID\n");
printf("\t<message-type> is one of: ");
- for (i=0; msg_types[i].name; i++) printf("%s, ", msg_types[i].name);
+ for (i=0; msg_types[i].name; i++)
+ printf("%s%s", i?", ":"",msg_types[i].name);
printf("\n");
if (doexit) exit(1);
}
static int pong_count;
+static BOOL got_level;
+static BOOL pong_registered = False;
+static BOOL debuglevel_registered = False;
+
/****************************************************************************
a useful function for testing the message system
@@ -57,6 +64,19 @@ a useful function for testing the message system
void pong_function(int msg_type, pid_t src, void *buf, size_t len)
{
pong_count++;
+ printf("PONG\n");
+}
+
+/****************************************************************************
+Prints out the current Debug level returned by MSG_DEBUGLEVEL
+****************************************************************************/
+void debuglevel_function(int msg_type, pid_t src, void *buf, size_t len)
+{
+ int level;
+ memcpy(&level, buf, sizeof(int));
+
+ printf("Current debug level is %d\n",level);
+ got_level = True;
}
/****************************************************************************
@@ -123,6 +143,25 @@ static BOOL do_command(char *dest, char *msg_name, char *params)
send_message(dest, MSG_DEBUG, &v, sizeof(int));
break;
+ case MSG_PROFILE:
+ if (!params) {
+ fprintf(stderr,"MSG_PROFILE needs a parameter\n");
+ return(False);
+ }
+ if (strequal(params, "on")) {
+ v = 2;
+ } else if (strequal(params, "off")) {
+ v = 0;
+ } else if (strequal(params, "count")) {
+ v = 1;
+ } else {
+ fprintf(stderr,
+ "MSG_PROFILE parameter must be on, off, or count\n");
+ return(False);
+ }
+ send_message(dest, MSG_PROFILE, &v, sizeof(int));
+ break;
+
case MSG_FORCE_ELECTION:
if (!strequal(dest, "nmbd")) {
fprintf(stderr,"force-election can only be sent to nmbd\n");
@@ -131,13 +170,31 @@ static BOOL do_command(char *dest, char *msg_name, char *params)
send_message(dest, MSG_FORCE_ELECTION, NULL, 0);
break;
+ case MSG_REQ_DEBUGLEVEL:
+ if (!debuglevel_registered) {
+ message_register(MSG_DEBUGLEVEL, debuglevel_function);
+ debuglevel_registered = True;
+ }
+ if (strequal(dest, "nmbd") || strequal(dest, "smbd")) {
+ fprintf(stderr,"debuglevel can only be sent to a PID\n");
+ return(False);
+ }
+ got_level = False;
+ send_message(dest, MSG_REQ_DEBUGLEVEL, NULL, 0);
+ while (!got_level) message_dispatch();
+ break;
+
case MSG_PING:
- message_register(MSG_PONG, pong_function);
+ if (!pong_registered) {
+ message_register(MSG_PONG, pong_function);
+ pong_registered = True;
+ }
if (!params) {
fprintf(stderr,"MSG_PING needs a parameter\n");
return(False);
}
n = atoi(params);
+ pong_count = 0;
for (i=0;i<n;i++) {
send_message(dest, MSG_PING, NULL, 0);
}