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)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85534 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2007-10-13 05:53:19 +00:00
parent fbcd884e1b
commit eec3f78368
3 changed files with 22 additions and 13 deletions

View File

@@ -85,7 +85,7 @@ int ast_unregister_verbose(void (*verboser)(const char *string));
void ast_console_puts(const char *string); void ast_console_puts(const char *string);
void ast_console_puts_mutable(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__ #define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__

View File

@@ -857,15 +857,17 @@ int ast_safe_system(const char *s)
/*! /*!
* \brief mute or unmute a console from logging * \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; int x;
for (x = 0;x < AST_MAX_CONNECTS; x++) { for (x = 0;x < AST_MAX_CONNECTS; x++) {
if (fd == consoles[x].fd) { if (fd == consoles[x].fd) {
if (consoles[x].mute) { if (consoles[x].mute) {
consoles[x].mute = 0; consoles[x].mute = 0;
if (!silent)
ast_cli(fd, "Console is not muted anymore.\n"); ast_cli(fd, "Console is not muted anymore.\n");
} else { } else {
consoles[x].mute = 1; consoles[x].mute = 1;
if (!silent)
ast_cli(fd, "Console is muted.\n"); ast_cli(fd, "Console is muted.\n");
} }
return; return;
@@ -1022,7 +1024,7 @@ static void *listener(void *unused)
flags = fcntl(consoles[x].p[1], F_GETFL); flags = fcntl(consoles[x].p[1], F_GETFL);
fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK); fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK);
consoles[x].fd = s; 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])) { 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)); ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno));
close(consoles[x].p[0]); close(consoles[x].p[0]);
@@ -2281,13 +2283,15 @@ static void ast_remotecontrol(char * data)
pid = atoi(cpid); pid = atoi(cpid);
else else
pid = -1; pid = -1;
if (!data) {
snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose); snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose);
fdprint(ast_consock, tmp); fdprint(ast_consock, tmp);
snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug); snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug);
fdprint(ast_consock, tmp); fdprint(ast_consock, tmp);
if (ast_opt_mute) { if (!ast_opt_mute)
ast_copy_string(tmp, "log and verbose output currently muted ('logger unmute' to unmute)", sizeof(tmp)); fdprint(ast_consock, "logger mute silent");
fdprint(ast_consock, tmp); 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); ast_verbose("Connected to Asterisk %s currently running on %s (pid = %d)\n", version, hostname, pid);
remotehostname = hostname; remotehostname = hostname;

View File

@@ -371,9 +371,14 @@ static char *handle_logger_mute(struct ast_cli_entry *e, int cmd, struct ast_cli
return NULL; return NULL;
} }
if (a->argc != 2) if (a->argc < 2 || a->argc > 3)
return CLI_SHOWUSAGE; 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; return CLI_SUCCESS;
} }