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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@30630 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Russell Bryant 20 years ago
parent 79161454a3
commit 0f912e5926

@ -85,6 +85,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
be useful to prevent a system from being brought down by terminating

@ -160,7 +160,6 @@ struct ast_flags ast_options = { AST_DEFAULT_OPTIONS };
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 @@ int ast_safe_system(const char *s)
/*!
* 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 @@ void ast_console_mute(int fd) {
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 @@ static void *listener(void *unused)
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 @@ static void ast_remotecontrol(char * data)
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 @@ int main(int argc, char *argv[])
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))

@ -222,7 +222,7 @@ static int handle_logger_mute(int fd, int argc, char *argv[])
{
if (argc != 2)
return RESULT_SHOWUSAGE;
ast_console_mute(fd);
ast_console_toggle_mute(fd);
return RESULT_SUCCESS;
}
@ -928,11 +928,11 @@ static struct ast_cli_entry builtins[] = {
{ { "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 },

@ -82,8 +82,8 @@ int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int re
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__

@ -76,6 +76,8 @@ enum ast_option_flags {
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 @@ enum ast_option_flags {
#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;

Loading…
Cancel
Save