[asterisk-commits] russell: trunk r85534 - in /trunk: ./ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Oct 13 00:53:19 CDT 2007


Author: russell
Date: Sat Oct 13 00:53:19 2007
New Revision: 85534

URL: http://svn.digium.com/view/asterisk?view=rev&rev=85534
Log:
Merged revisions 85533 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r85533 | russell | 2007-10-13 01:48:10 -0400 (Sat, 13 Oct 2007) | 12 lines

Fix an issue with console verbosity when running asterisk -rx to execute a command
and retrieve its output.  The issue was that there was no way for the main Asterisk
process to know that the remote console was connecting in the -rx mode.  The way that
James has fixed this is to have all remote consoles muted by default.  Then, regular
remote consoles automatically execute a CLI command to unmute themselves when they
first start up.

(closes issue #10847)
Reported by: atis
Patches: 
      asterisk-consolemute.diff.txt uploaded by jamesgolovich (license 176)

........

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/logger.h
    trunk/main/asterisk.c
    trunk/main/cli.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/include/asterisk/logger.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/logger.h?view=diff&rev=85534&r1=85533&r2=85534
==============================================================================
--- trunk/include/asterisk/logger.h (original)
+++ trunk/include/asterisk/logger.h Sat Oct 13 00:53:19 2007
@@ -85,7 +85,7 @@
 void ast_console_puts(const char *string);
 
 void ast_console_puts_mutable(const char *string);
-void ast_console_toggle_mute(int fd);
+void ast_console_toggle_mute(int fd, int silent);
 
 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
 

Modified: trunk/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/main/asterisk.c?view=diff&rev=85534&r1=85533&r2=85534
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Sat Oct 13 00:53:19 2007
@@ -857,16 +857,18 @@
 /*!
  * \brief mute or unmute a console from logging
  */
-void ast_console_toggle_mute(int fd) {
+void ast_console_toggle_mute(int fd, int silent) {
 	int x;
 	for (x = 0;x < AST_MAX_CONNECTS; x++) {
 		if (fd == consoles[x].fd) {
 			if (consoles[x].mute) {
 				consoles[x].mute = 0;
-				ast_cli(fd, "Console is not muted anymore.\n");
+				if (!silent)
+					ast_cli(fd, "Console is not muted anymore.\n");
 			} else {
 				consoles[x].mute = 1;
-				ast_cli(fd, "Console is muted.\n");
+				if (!silent)
+					ast_cli(fd, "Console is muted.\n");
 			}
 			return;
 		}
@@ -1022,7 +1024,7 @@
 					flags = fcntl(consoles[x].p[1], F_GETFL);
 					fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK);
 					consoles[x].fd = s;
-					consoles[x].mute = ast_opt_mute;
+					consoles[x].mute = 1; /* Default is muted, we will un-mute if necessary */
 					if (ast_pthread_create_detached_background(&consoles[x].t, NULL, netconsole, &consoles[x])) {
 						ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno));
 						close(consoles[x].p[0]);
@@ -2281,13 +2283,15 @@
 		pid = atoi(cpid);
 	else
 		pid = -1;
-	snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose);
-	fdprint(ast_consock, tmp);
-	snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug);
-	fdprint(ast_consock, tmp);
-	if (ast_opt_mute) {
-		ast_copy_string(tmp, "log and verbose output currently muted ('logger unmute' to unmute)", sizeof(tmp));
+	if (!data) {
+		snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose);
 		fdprint(ast_consock, tmp);
+		snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug);
+		fdprint(ast_consock, tmp);
+		if (!ast_opt_mute)
+			fdprint(ast_consock, "logger mute silent");
+		else 
+			printf("log and verbose output currently muted ('logger mute' to unmute)\n");
 	}
 	ast_verbose("Connected to Asterisk %s currently running on %s (pid = %d)\n", version, hostname, pid);
 	remotehostname = hostname;

Modified: trunk/main/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/main/cli.c?view=diff&rev=85534&r1=85533&r2=85534
==============================================================================
--- trunk/main/cli.c (original)
+++ trunk/main/cli.c Sat Oct 13 00:53:19 2007
@@ -371,9 +371,14 @@
 		return NULL;
 	}
 
-	if (a->argc != 2)
+	if (a->argc < 2 || a->argc > 3)
 		return CLI_SHOWUSAGE;
-	ast_console_toggle_mute(a->fd);
+
+	if (a->argc == 3 && !strcasecmp(argv[2], "silent"))
+		ast_console_toggle_mute(a->fd, 1);
+	else
+		ast_console_toggle_mute(a->fd, 0);
+
 	return CLI_SUCCESS;
 }
 




More information about the asterisk-commits mailing list