[asterisk-commits] trunk r30630 - in /trunk: ./ include/asterisk/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri May 26 14:47:53 MST 2006


Author: russell
Date: Fri May 26 16:47:52 2006
New Revision: 30630

URL: http://svn.digium.com/view/asterisk?rev=30630&view=rev
Log:
Fix various problems in the addition of the ability to mute log/verbose
output to remove consoles. The prototypes added to logger.h still need
doxygen documentation, as well.

- Add the new command line option to the man page
- make the mute option a flag instead of an int since it is only a binary
  option
- remove useless extern keywords for prototypes added to logger.h
- rename ast_console_mute() to ast_console_toggle_mute() since that is what
  it actually does
- actually apply the mute option to newly created remote consoles instead of
  only working when the CLI command is used
- don't imply the NO_FORK option if the mute command line option is provided
- place the new CLI command in the correct place in the list which has to be
  in alphabetical order
- Finally, clean up a few spacing issues to conform to the coding guidelines

Modified:
    trunk/asterisk.8
    trunk/asterisk.c
    trunk/cli.c
    trunk/include/asterisk/logger.h
    trunk/include/asterisk/options.h

Modified: trunk/asterisk.8
URL: http://svn.digium.com/view/asterisk/trunk/asterisk.8?rev=30630&r1=30629&r2=30630&view=diff
==============================================================================
--- trunk/asterisk.8 (original)
+++ trunk/asterisk.8 Fri May 26 16:47:52 2006
@@ -84,6 +84,9 @@
 Limits the maximum load average before rejecting new calls.  This can
 be useful to prevent a system from being brought down by terminating
 too many simultaneous calls.
+.TP
+\fB-m\fR
+Disable log and verbose output to remote (-r) consoles.
 .TP
 \fB-M \fIvalue\fB\fR
 Limits the maximum number of calls to the specified value.  This can

Modified: trunk/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/asterisk.c?rev=30630&r1=30629&r2=30630&view=diff
==============================================================================
--- trunk/asterisk.c (original)
+++ trunk/asterisk.c Fri May 26 16:47:52 2006
@@ -160,7 +160,6 @@
 
 int option_verbose = 0;				/*!< Verbosity level */
 int option_debug = 0;				/*!< Debug level */
-int option_mute = 0;				/*!< Mute console */
 
 double option_maxload = 0.0;			/*!< Max load avg on system */
 int option_maxcalls = 0;			/*!< Max number of active calls */
@@ -685,15 +684,15 @@
 /*!
  * mute or unmute a console from logging
  */
-void ast_console_mute(int fd) {
+void ast_console_toggle_mute(int fd) {
 	int x;
-	for (x=0;x<AST_MAX_CONNECTS; x++) {
+	for (x = 0;x < AST_MAX_CONNECTS; x++) {
 		if (fd == consoles[x].fd) {
 			if (consoles[x].mute) {
-				consoles[x].mute=0;
+				consoles[x].mute = 0;
 				ast_cli(fd, "Console is not muted anymore.\n");
 			} else {
-				consoles[x].mute=1;
+				consoles[x].mute = 1;
 				ast_cli(fd, "Console is muted.\n");
 			}
 			return;
@@ -708,9 +707,9 @@
 static void ast_network_puts_mutable(const char *string)
 {
 	int x;
-	for (x=0;x < AST_MAX_CONNECTS; x++) {
+	for (x = 0;x < AST_MAX_CONNECTS; x++) {
 		if (consoles[x].mute)
-			continue;;
+			continue;
 		if (consoles[x].fd > -1) 
 			fdprint(consoles[x].p[1], string);
 	}
@@ -866,7 +865,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 = 0;
+					consoles[x].mute = ast_opt_mute;
 					if (ast_pthread_create(&consoles[x].t, &attr, netconsole, &consoles[x])) {
 						ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno));
 						close(consoles[x].p[0]);
@@ -2073,8 +2072,8 @@
 	fdprint(ast_consock, tmp);
 	snprintf(tmp, sizeof(tmp), "set debug atleast %d", option_debug);
 	fdprint(ast_consock, tmp);
-	if (option_mute) {
-		snprintf(tmp, sizeof(tmp), "logger mute");
+	if (ast_opt_mute) {
+		snprintf(tmp, sizeof(tmp), "log and verbose output currently muted ('logger unmute' to unmute)");
 		fdprint(ast_consock, tmp);
 	}
 	ast_verbose("Connected to Asterisk %s currently running on %s (pid = %d)\n", version, hostname, pid);
@@ -2396,8 +2395,7 @@
 			ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
 			break;
 		case 'm':
-			option_mute++;
-			ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
+			ast_set_flag(&ast_options, AST_OPT_FLAG_MUTE);
 			break;
 		case 'M':
 			if ((sscanf(optarg, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0))

Modified: trunk/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/cli.c?rev=30630&r1=30629&r2=30630&view=diff
==============================================================================
--- trunk/cli.c (original)
+++ trunk/cli.c Fri May 26 16:47:52 2006
@@ -222,7 +222,7 @@
 {
 	if (argc != 2)
 		return RESULT_SHOWUSAGE;
-	ast_console_mute(fd);
+	ast_console_toggle_mute(fd);
 	return RESULT_SUCCESS;
 }
 
@@ -928,11 +928,11 @@
 	{ { "group", "show", "channels", NULL }, group_show_channels, "Show active channels with group(s)", group_show_channels_help},
 	{ { "help", NULL }, handle_help, "Display help list, or specific help on a command", help_help, complete_help },
 	{ { "load", NULL }, handle_load, "Load a dynamic module by name", load_help, complete_fn },
+	{ { "logger", "mute", NULL }, handle_logger_mute, "Toggle logging output to a console", logger_mute_help },
 	{ { "no", "debug", "channel", NULL }, handle_nodebugchan, "Disable debugging on a channel", nodebugchan_help, complete_ch_4 },
 	{ { "reload", NULL }, handle_reload, "Reload configuration", reload_help, complete_mod_2 },
 	{ { "set", "debug", NULL }, handle_set_debug, "Set level of debug chattiness", set_debug_help },
 	{ { "set", "verbose", NULL }, handle_set_verbose, "Set level of verboseness", set_verbose_help },
-	{ { "logger", "mute", NULL }, handle_logger_mute, "Disable logging output to a console", logger_mute_help },
 	{ { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch_3 },
 	{ { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help, complete_show_channels },
 	{ { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },

Modified: trunk/include/asterisk/logger.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/logger.h?rev=30630&r1=30629&r2=30630&view=diff
==============================================================================
--- trunk/include/asterisk/logger.h (original)
+++ trunk/include/asterisk/logger.h Fri May 26 16:47:52 2006
@@ -82,8 +82,8 @@
 int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
 void ast_console_puts(const char *string);
 
-extern void ast_console_puts_mutable(const char *string);
-extern void ast_console_mute(int fd);
+void ast_console_puts_mutable(const char *string);
+void ast_console_toggle_mute(int fd);
 
 #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
 

Modified: trunk/include/asterisk/options.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/options.h?rev=30630&r1=30629&r2=30630&view=diff
==============================================================================
--- trunk/include/asterisk/options.h (original)
+++ trunk/include/asterisk/options.h Fri May 26 16:47:52 2006
@@ -76,6 +76,8 @@
 	AST_OPT_FLAG_INTERNAL_TIMING = (1 << 20),
 	/*! Always fork, even if verbose or debug settings are non-zero */
 	AST_OPT_FLAG_ALWAYS_FORK = (1 << 21),
+	/*! Disable log/verbose output to remote consoles */
+	AST_OPT_FLAG_MUTE = (1 << 22)
 };
 
 /*! These are the options that set by default when Asterisk starts */
@@ -103,6 +105,7 @@
 #define ast_opt_end_cdr_before_h_exten	ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN)
 #define ast_opt_internal_timing		ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING)
 #define ast_opt_always_fork		ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
+#define ast_opt_mute			ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)
 
 extern struct ast_flags ast_options;
 



More information about the asterisk-commits mailing list