[Asterisk-code-review] bridge_channel: Don't queue unmapped frames. (asterisk[16])

Joshua Colp asteriskteam at digium.com
Fri Jun 5 04:52:14 CDT 2020


Joshua Colp has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14503 )


Change subject: bridge_channel: Don't queue unmapped frames.
......................................................................

bridge_channel: Don't queue unmapped frames.

If a frame is written to a channel in a bridge we
would normally queue this frame up and the channel
thread would then act upon it. If this frame had no
stream mapping on the channel it would then be
discarded.

This change adds a check before the queueing occurs
to determine if a mapping exists. If it does not
exist then the frame is not even queued at all. This
stops a frame duplication from happening and from
the channel thread having to wake up and deal with
it.

Change-Id: I17189b9b1dec45fc7e4490e8081d444a25a00bda
---
M main/bridge_channel.c
1 file changed, 15 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/03/14503/1

diff --git a/main/bridge_channel.c b/main/bridge_channel.c
index 8566187..7f2b01e 100644
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -1043,6 +1043,21 @@
 		return 0;
 	}
 
+	if (fr->stream_num > -1) {
+		int num = -1;
+
+		ast_bridge_channel_lock(bridge_channel);
+		if (fr->stream_num < (int)AST_VECTOR_SIZE(&bridge_channel->stream_map.to_channel)) {
+			num = AST_VECTOR_GET(&bridge_channel->stream_map.to_channel, fr->stream_num);
+		}
+		ast_bridge_channel_unlock(bridge_channel);
+
+		if (num == -1) {
+			/* We don't have a mapped stream so just discard this frame. */
+			return 0;
+		}
+	}
+
 	dup = ast_frdup(fr);
 	if (!dup) {
 		return -1;

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14503
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I17189b9b1dec45fc7e4490e8081d444a25a00bda
Gerrit-Change-Number: 14503
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200605/dda5457d/attachment.html>


More information about the asterisk-code-review mailing list