[Asterisk-code-review] message.c: Add option to make the global Message channel "internal" (asterisk[16])
George Joseph
asteriskteam at digium.com
Mon Feb 3 10:33:43 CST 2020
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13723 )
Change subject: message.c: Add option to make the global Message channel "internal"
......................................................................
message.c: Add option to make the global Message channel "internal"
In order to reduce the amount of AMI events generated, the global
"Message/ast_msg_queue" channel created by message.c can be marked
as "internal". This suppresses channel events such as "Newexten",
"VarSet", etc. and can greatly reduce load on the manager when the
Digium Phone Module for Asterisk is in use. The option controlling
the suppression is "message_channel_is_internal" in asterisk.conf.
In Asterisk versions <18, the default is "no" preserving existing
behavior. Beginning with Asterisk 18, the option will default to
"yes".
* Added the "message_channel_is_internal" option to asterisk.conf.
* Changed message.c to set the AST_CHAN_TP_INTERNAL property on
the "Message/ast_msg_queue" channel if the option is set in
asterisk.conf.
Change-Id: Ia2e3516d43f4e0df994fc6598565d6bba2d7018b
---
M configs/samples/asterisk.conf.sample
A doc/CHANGES-staging/messaging-channel-internal
M include/asterisk/options.h
M main/asterisk.c
M main/message.c
M main/options.c
6 files changed, 27 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/23/13723/1
diff --git a/configs/samples/asterisk.conf.sample b/configs/samples/asterisk.conf.sample
index 5f33abb..16c4881 100644
--- a/configs/samples/asterisk.conf.sample
+++ b/configs/samples/asterisk.conf.sample
@@ -118,6 +118,11 @@
; calls are not accepted by a remote
; implementation, please report this and go
; back to value 96.
+;message_channel_is_internal = no; This option, if enabled, will
+ ; cause the global Message/ast_msg_queue channel
+ ; to be marked as "internal". This suppresses
+ ; all of the channel's AMI channel events which
+ ; can reduce the load on the manager.
; Changing the following lines may compromise your security.
;[files]
diff --git a/doc/CHANGES-staging/messaging-channel-internal b/doc/CHANGES-staging/messaging-channel-internal
new file mode 100644
index 0000000..58ca4a7
--- /dev/null
+++ b/doc/CHANGES-staging/messaging-channel-internal
@@ -0,0 +1,11 @@
+Subject: Messaging
+
+In order to reduce the amount of AMI events generated, the global
+"Message/ast_msg_queue" channel created by message.c can be marked
+as "internal". This suppresses channel events such as "Newexten",
+"VarSet", etc. and can greatly reduce load on the manager when the
+Digium Phone Module for Asterisk is in use. The option controlling
+the suppression is "message_channel_is_internal" in asterisk.conf.
+In Asterisk versions <18, the default is "no" preserving existing
+behavior. Beginning with Asterisk 18, the option will default to
+"yes".
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index 6c4e552..fe65ba2 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -84,6 +84,8 @@
AST_OPT_FLAG_DEBUG_MODULE = (1 << 23),
/*! Terminal colors should be adjusted for a light-colored background */
AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25),
+ /*! Make the global Message channel an internal channel to suppress AMI events */
+ AST_OPT_FLAG_MESSAGE_CHANNEL_IS_INTERNAL = (1 << 26),
/*! Force black background */
AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27),
/*! Hide remote console connect messages on console */
@@ -129,6 +131,7 @@
#define ast_opt_generic_plc ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC)
#define ast_opt_ref_debug ast_test_flag(&ast_options, AST_OPT_FLAG_REF_DEBUG)
#define ast_opt_generic_plc_on_equal_codecs ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)
+#define ast_opt_message_channel_is_internal ast_test_flag(&ast_options, AST_OPT_FLAG_MESSAGE_CHANNEL_IS_INTERNAL)
/*! Maximum log level defined by PJPROJECT. */
#define MAX_PJ_LOG_MAX_LEVEL 6
diff --git a/main/asterisk.c b/main/asterisk.c
index 38084b4..6553efc 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -506,6 +506,7 @@
ast_cli(a->fd, " Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled");
ast_cli(a->fd, " Generic PLC: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) ? "Enabled" : "Disabled");
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");
+ ast_cli(a->fd, " Message Channel is Internal: %s\n", ast_opt_message_channel_is_internal ? "Enabled" : "Disabled");
ast_cli(a->fd, " Min DTMF duration:: %u\n", option_dtmfminduration);
#if !defined(LOW_MEMORY)
ast_cli(a->fd, " Cache media frames: %s\n", ast_opt_cache_media_frames ? "Enabled" : "Disabled");
diff --git a/main/message.c b/main/message.c
index 4874162..32654fb 100644
--- a/main/message.c
+++ b/main/message.c
@@ -283,7 +283,7 @@
* This will not be registered as we never want anything to try
* to create Message channels other than internally in this file.
*/
-static const struct ast_channel_tech msg_chan_tech_hack = {
+static struct ast_channel_tech msg_chan_tech_hack = {
.type = "Message",
.description = "Internal Text Message Processing",
.read = chan_msg_read,
@@ -685,6 +685,10 @@
return NULL;
}
+ if (ast_opt_message_channel_is_internal) {
+ msg_chan_tech_hack.properties |= AST_CHAN_TP_INTERNAL;
+ }
+
ast_channel_tech_set(chan, &msg_chan_tech_hack);
ast_channel_unlock(chan);
ast_channel_unlink(chan);
diff --git a/main/options.c b/main/options.c
index 1da787f..d613d9d 100644
--- a/main/options.c
+++ b/main/options.c
@@ -464,6 +464,8 @@
}
} else if (!strcasecmp(v->name, "live_dangerously")) {
live_dangerously = ast_true(v->value);
+ } else if (!strcasecmp(v->name, "message_channel_is_internal")) {
+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_MESSAGE_CHANNEL_IS_INTERNAL);
}
}
if (!ast_opt_remote) {
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13723
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ia2e3516d43f4e0df994fc6598565d6bba2d7018b
Gerrit-Change-Number: 13723
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200203/89981c80/attachment-0001.html>
More information about the asterisk-code-review
mailing list