From 525bbf7d4eab8f9953bff26388a0a41c3bf2939a Mon Sep 17 00:00:00 2001
From: Mark Michelson <mmichelson@digium.com>
Date: Wed, 22 Jul 2015 09:46:29 -0500
Subject: [PATCH] Local channels: Do not block control -1 payloads.

Control frames with a -1 payload are used as a special signal to stop
playtones generators on channels. This indication is sent both by
app_dial as well as by ast_answer() when a call is answered in case any
tones were being generated on a calling channel.

This control frame type was made to stop traversing local channel pairs
as an optimization, because it was thought that it was unnecessary to
send these indications, and allowing such unnecessary control frames to
traverse the local channels would cause the local channels to optimize
away less quickly.

As it turns out, through some special magic dialplan code, it is
possible to have a tones being played on a non-local channel, and it is
important for the local channel to convey that the tones should be
stopped. The result of having tones continue to be played on the
non-local channel is that the tones play even once the channel has been
bridged. By not blocking the -1 control frame type, we can ensure that
this situation does not happen.

ASTERISK-25250 #close
Reported by Etienne Lessard

Change-Id: I40227e4249d6d61dc6a9b08bbe9ee3aa18be7e30
---
 channels/chan_local.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/channels/chan_local.c b/channels/chan_local.c
index d57df1b8f7..794bbae8b7 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -754,12 +754,7 @@ static int local_indicate(struct ast_channel *ast, int condition, const void *da
 	} else {
 		/* Queue up a frame representing the indication as a control frame */
 		ao2_lock(p);
-		/*
-		 * Block -1 stop tones events if we are to be optimized out.  We
-		 * don't need a flurry of these events on a local channel chain
-		 * when initially connected to slow the optimization process.
-		 */
-		if (0 <= condition || ast_test_flag(p, LOCAL_NO_OPTIMIZATION)) {
+		if (ast_test_flag(p, LOCAL_NO_OPTIMIZATION)) {
 			isoutbound = IS_OUTBOUND(ast, p);
 			f.subclass.integer = condition;
 			f.data.ptr = (void *) data;
-- 
GitLab