From ca4acd520e01a568266f13e3c4ce77ce2ed8d77e Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Thu, 12 Oct 2000 00:29:01 +0000 Subject: print source PID in PONG and debuglevel message. Allow request debuglevel message to go to any dest. Put timeout for commands that expect a reply. sync with 2.2 branch (This used to be commit 45632bb813da06d0139aa32b9ab99d472dcfaf25) --- source3/utils/smbcontrol.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'source3/utils/smbcontrol.c') diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 3d17ec1123..dff0dd3300 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -35,6 +35,10 @@ static struct { {NULL, -1} }; +time_t timeout_start; + +#define MAX_WAIT 10 + static void usage(BOOL doexit) { int i; @@ -64,7 +68,7 @@ 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"); + printf("PONG from PID %d\n",src); } /**************************************************************************** @@ -75,7 +79,7 @@ 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); + printf("Current debug level of PID %d is %d\n",src,level); got_level = True; } @@ -126,6 +130,7 @@ static BOOL do_command(char *dest, char *msg_name, char *params) { int i, n, v; int mtype; + BOOL retval; mtype = parse_type(msg_name); if (mtype == -1) { @@ -177,13 +182,18 @@ static BOOL do_command(char *dest, char *msg_name, char *params) 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(); + retval = send_message(dest, MSG_REQ_DEBUGLEVEL, NULL, 0); + if (retval) { + timeout_start = time(NULL); + while (!got_level) { + message_dispatch(); + if ((time(NULL) - timeout_start) > MAX_WAIT) { + fprintf(stderr,"debuglevel timeout\n"); + break; + } + } + } break; case MSG_PING: @@ -198,9 +208,19 @@ static BOOL do_command(char *dest, char *msg_name, char *params) n = atoi(params); pong_count = 0; for (i=0;i MAX_WAIT) { + fprintf(stderr,"PING timeout\n"); + break; + } + } } - while (pong_count < n) message_dispatch(); break; } -- cgit