<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13723">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">message.c: Add option to make the global Message channel "internal"<br><br>In order to reduce the amount of AMI events generated, the global<br>"Message/ast_msg_queue" channel created by message.c can be marked<br>as "internal".  This suppresses channel events such as "Newexten",<br>"VarSet", etc. and can greatly reduce load on the manager when the<br>Digium Phone Module for Asterisk is in use.  The option controlling<br>the suppression is "message_channel_is_internal" in asterisk.conf.<br>In Asterisk versions <18, the default is "no" preserving existing<br>behavior.  Beginning with Asterisk 18, the option will default to<br>"yes".<br><br>* Added the "message_channel_is_internal" option to asterisk.conf.<br><br>* Changed message.c to set the AST_CHAN_TP_INTERNAL property on<br>  the "Message/ast_msg_queue" channel if the option is set in<br>  asterisk.conf.<br><br>Change-Id: Ia2e3516d43f4e0df994fc6598565d6bba2d7018b<br>---<br>M configs/samples/asterisk.conf.sample<br>A doc/CHANGES-staging/messaging-channel-internal<br>M include/asterisk/options.h<br>M main/asterisk.c<br>M main/message.c<br>M main/options.c<br>6 files changed, 27 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/23/13723/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configs/samples/asterisk.conf.sample b/configs/samples/asterisk.conf.sample</span><br><span>index 5f33abb..16c4881 100644</span><br><span>--- a/configs/samples/asterisk.conf.sample</span><br><span>+++ b/configs/samples/asterisk.conf.sample</span><br><span>@@ -118,6 +118,11 @@</span><br><span>                            ; calls are not accepted by a remote</span><br><span>                                 ; implementation, please report this and go</span><br><span>                          ; back to value 96.</span><br><span style="color: hsl(120, 100%, 40%);">+;message_channel_is_internal = no;  This option, if enabled, will</span><br><span style="color: hsl(120, 100%, 40%);">+                ; cause the global Message/ast_msg_queue channel</span><br><span style="color: hsl(120, 100%, 40%);">+                ; to be marked as "internal".  This suppresses</span><br><span style="color: hsl(120, 100%, 40%);">+                ; all of the channel's AMI channel events which</span><br><span style="color: hsl(120, 100%, 40%);">+                ; can reduce the load on the manager.</span><br><span> </span><br><span> ; Changing the following lines may compromise your security.</span><br><span> ;[files]</span><br><span>diff --git a/doc/CHANGES-staging/messaging-channel-internal b/doc/CHANGES-staging/messaging-channel-internal</span><br><span>new file mode 100644</span><br><span>index 0000000..58ca4a7</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/messaging-channel-internal</span><br><span>@@ -0,0 +1,11 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: Messaging</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+In order to reduce the amount of AMI events generated, the global</span><br><span style="color: hsl(120, 100%, 40%);">+"Message/ast_msg_queue" channel created by message.c can be marked</span><br><span style="color: hsl(120, 100%, 40%);">+as "internal".  This suppresses channel events such as "Newexten",</span><br><span style="color: hsl(120, 100%, 40%);">+"VarSet", etc. and can greatly reduce load on the manager when the</span><br><span style="color: hsl(120, 100%, 40%);">+Digium Phone Module for Asterisk is in use.  The option controlling</span><br><span style="color: hsl(120, 100%, 40%);">+the suppression is "message_channel_is_internal" in asterisk.conf.</span><br><span style="color: hsl(120, 100%, 40%);">+In Asterisk versions <18, the default is "no" preserving existing</span><br><span style="color: hsl(120, 100%, 40%);">+behavior.  Beginning with Asterisk 18, the option will default to</span><br><span style="color: hsl(120, 100%, 40%);">+"yes".</span><br><span>diff --git a/include/asterisk/options.h b/include/asterisk/options.h</span><br><span>index 6c4e552..fe65ba2 100644</span><br><span>--- a/include/asterisk/options.h</span><br><span>+++ b/include/asterisk/options.h</span><br><span>@@ -84,6 +84,8 @@</span><br><span>        AST_OPT_FLAG_DEBUG_MODULE = (1 << 23),</span><br><span>         /*! Terminal colors should be adjusted for a light-colored background */</span><br><span>     AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25),</span><br><span style="color: hsl(120, 100%, 40%);">+      /*! Make the global Message channel an internal channel to suppress AMI events */</span><br><span style="color: hsl(120, 100%, 40%);">+     AST_OPT_FLAG_MESSAGE_CHANNEL_IS_INTERNAL = (1 << 26),</span><br><span>  /*! Force black background */</span><br><span>        AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27),</span><br><span>       /*! Hide remote console connect messages on console */</span><br><span>@@ -129,6 +131,7 @@</span><br><span> #define ast_opt_generic_plc         ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC)</span><br><span> #define ast_opt_ref_debug           ast_test_flag(&ast_options, AST_OPT_FLAG_REF_DEBUG)</span><br><span> #define ast_opt_generic_plc_on_equal_codecs  ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)</span><br><span style="color: hsl(120, 100%, 40%);">+#define ast_opt_message_channel_is_internal  ast_test_flag(&ast_options, AST_OPT_FLAG_MESSAGE_CHANNEL_IS_INTERNAL)</span><br><span> </span><br><span> /*! Maximum log level defined by PJPROJECT. */</span><br><span> #define MAX_PJ_LOG_MAX_LEVEL            6</span><br><span>diff --git a/main/asterisk.c b/main/asterisk.c</span><br><span>index 38084b4..6553efc 100644</span><br><span>--- a/main/asterisk.c</span><br><span>+++ b/main/asterisk.c</span><br><span>@@ -506,6 +506,7 @@</span><br><span>     ast_cli(a->fd, "  Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled");</span><br><span>     ast_cli(a->fd, "  Generic PLC:                 %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) ? "Enabled" : "Disabled");</span><br><span>  ast_cli(a->fd, "  Generic PLC on equal codecs: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS) ? "Enabled" : "Disabled");</span><br><span style="color: hsl(120, 100%, 40%);">+   ast_cli(a->fd, "  Message Channel is Internal: %s\n", ast_opt_message_channel_is_internal ? "Enabled" : "Disabled");</span><br><span>        ast_cli(a->fd, "  Min DTMF duration::          %u\n", option_dtmfminduration);</span><br><span> #if !defined(LOW_MEMORY)</span><br><span>      ast_cli(a->fd, "  Cache media frames:          %s\n", ast_opt_cache_media_frames ? "Enabled" : "Disabled");</span><br><span>diff --git a/main/message.c b/main/message.c</span><br><span>index 4874162..32654fb 100644</span><br><span>--- a/main/message.c</span><br><span>+++ b/main/message.c</span><br><span>@@ -283,7 +283,7 @@</span><br><span>  * This will not be registered as we never want anything to try</span><br><span>  * to create Message channels other than internally in this file.</span><br><span>  */</span><br><span style="color: hsl(0, 100%, 40%);">-static const struct ast_channel_tech msg_chan_tech_hack = {</span><br><span style="color: hsl(120, 100%, 40%);">+static struct ast_channel_tech msg_chan_tech_hack = {</span><br><span>     .type             = "Message",</span><br><span>     .description      = "Internal Text Message Processing",</span><br><span>    .read             = chan_msg_read,</span><br><span>@@ -685,6 +685,10 @@</span><br><span>            return NULL;</span><br><span>         }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_opt_message_channel_is_internal) {</span><br><span style="color: hsl(120, 100%, 40%);">+            msg_chan_tech_hack.properties |= AST_CHAN_TP_INTERNAL;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  ast_channel_tech_set(chan, &msg_chan_tech_hack);</span><br><span>         ast_channel_unlock(chan);</span><br><span>    ast_channel_unlink(chan);</span><br><span>diff --git a/main/options.c b/main/options.c</span><br><span>index 1da787f..d613d9d 100644</span><br><span>--- a/main/options.c</span><br><span>+++ b/main/options.c</span><br><span>@@ -464,6 +464,8 @@</span><br><span>                         }</span><br><span>            } else if (!strcasecmp(v->name, "live_dangerously")) {</span><br><span>                  live_dangerously = ast_true(v->value);</span><br><span style="color: hsl(120, 100%, 40%);">+             } else if (!strcasecmp(v->name, "message_channel_is_internal")) {</span><br><span style="color: hsl(120, 100%, 40%);">+                        ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_MESSAGE_CHANNEL_IS_INTERNAL);</span><br><span>            }</span><br><span>    }</span><br><span>    if (!ast_opt_remote) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13723">change 13723</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13723"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Ia2e3516d43f4e0df994fc6598565d6bba2d7018b </div>
<div style="display:none"> Gerrit-Change-Number: 13723 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>