[Asterisk-code-review] res_rtp_asterisk: prevent loop when receive buffer is flushed by a re... (asterisk[16])

Pirmin Walthert asteriskteam at digium.com
Tue Apr 14 10:56:54 CDT 2020


Pirmin Walthert has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14208 )


Change subject: res_rtp_asterisk: prevent loop when receive buffer is flushed by a received packet that is also in receive buffer with NACK
......................................................................

res_rtp_asterisk: prevent loop when receive buffer is flushed by a
received packet that is also in receive buffer with NACK

When the receive buffer was flushed by a received packet while the
it already contained a packet with the same sequence number,
asterisk never left the while loop which tried to order the packets.
Prevent this by making sure that the packet is only inserted once.

Change-Id: Idaa376101bc1ac880047c49feb6faee773e718b3
---
M res/res_rtp_asterisk.c
1 file changed, 10 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/08/14208/1

diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 739b17b..1d44c92 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -7825,7 +7825,7 @@
 			struct ast_rtp_rtcp_nack_payload *payload;
 
 			/* If the packet we received is the one we are expecting at this point then add it in */
-			if (rtp->expectedrxseqno == seqno) {
+			if (rtp->expectedrxseqno == seqno && !inserted) {
 				frame = ast_frdup(ast_rtp_interpret(instance, srtp, &addr, read_area, res, prev_seqno));
 				if (frame) {
 					AST_LIST_INSERT_TAIL(&frames, frame, frame_list);
@@ -7843,12 +7843,15 @@
 
 			payload = (struct ast_rtp_rtcp_nack_payload *)ast_data_buffer_remove(rtp->recv_buffer, rtp->expectedrxseqno);
 			if (payload) {
-				frame = ast_frdup(ast_rtp_interpret(instance, srtp, &addr, payload->buf, payload->size, prev_seqno));
-				if (frame) {
-					AST_LIST_INSERT_TAIL(&frames, frame, frame_list);
-					prev_seqno = rtp->expectedrxseqno;
-					ast_debug(2, "Emptying queue and returning packet with sequence number '%d' from RTP instance '%p'\n",
-						frame->seqno, instance);
+				//if the expectedrxseqno equals seqno this is an error or a duplicated packet...
+				if (rtp->expectedrxseqno != seqno) {
+					frame = ast_frdup(ast_rtp_interpret(instance, srtp, &addr, payload->buf, payload->size, prev_seqno));
+					if (frame) {
+						AST_LIST_INSERT_TAIL(&frames, frame, frame_list);
+						prev_seqno = rtp->expectedrxseqno;
+						ast_debug(2, "Emptying queue and returning packet with sequence number '%d' from RTP instance '%p'\n",
+							frame->seqno, instance);
+					}
 				}
 				ast_free(payload);
 			}

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Idaa376101bc1ac880047c49feb6faee773e718b3
Gerrit-Change-Number: 14208
Gerrit-PatchSet: 1
Gerrit-Owner: Pirmin Walthert <infos at nappsoft.ch>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200414/b8b9337e/attachment-0001.html>


More information about the asterisk-code-review mailing list