]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix an issue with console verbosity when running asterisk -rx to execute a command
authorRussell Bryant <russell@russellbryant.com>
Sat, 13 Oct 2007 05:48:10 +0000 (05:48 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sat, 13 Oct 2007 05:48:10 +0000 (05:48 +0000)
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/branches/1.4@85533 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/logger.h
main/asterisk.c
main/cli.c

index b4737d06cfddd93a139251a2ba9ee299a271d7dd..63b3cdbb0cdf5eb9d62554bb14d44c900f20b2a1 100644 (file)
@@ -83,7 +83,7 @@ int ast_unregister_verbose(void (*verboser)(const char *string));
 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__
 
index 9f0f049dee9227a15624874bb9437ee6f19e00c2..873828e2f20caed242a4db73b12b4a631a211652 100644 (file)
@@ -832,16 +832,18 @@ int ast_safe_system(const char *s)
 /*!
  * \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;
                }
@@ -1000,7 +1002,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 = ast_opt_mute;
+                                       consoles[x].mute = 1; /* Default is muted, we will un-mute if necessary */
                                        if (ast_pthread_create_background(&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]);
@@ -2256,13 +2258,15 @@ static void ast_remotecontrol(char * data)
                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) {
-               snprintf(tmp, sizeof(tmp), "log and verbose output currently muted ('logger unmute' to unmute)");
+       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;
index 826ed6f2a75479b3a178b1926ca7da053b178115..83e5c71cf24483bc2b652fda9b7a0962815158d2 100644 (file)
@@ -402,9 +402,12 @@ static int handle_debuglevel_deprecated(int fd, int argc, char *argv[])
 
 static int handle_logger_mute(int fd, int argc, char *argv[])
 {
-       if (argc != 2)
+       if (argc < 2 || argc > 3)
                return RESULT_SHOWUSAGE;
-       ast_console_toggle_mute(fd);
+       if (argc == 3 && !strcasecmp(argv[2], "silent"))
+               ast_console_toggle_mute(fd, 1);
+       else
+               ast_console_toggle_mute(fd, 0);
        return RESULT_SUCCESS;
 }