[Asterisk-code-review] res rtp asterisk: Avoid close the rtp/rtcp fd twice. (asterisk[15])

Jenkins2 asteriskteam at digium.com
Wed Dec 20 07:55:32 CST 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7668 )

Change subject: res_rtp_asterisk:  Avoid close the rtp/rtcp fd twice.
......................................................................

res_rtp_asterisk:  Avoid close the rtp/rtcp fd twice.

When RTCP-MUX enabled. rtp->s is the same as rtcp->s, check this before
close the file descriptor. Close the FD twice will hangs the asterisk
under heavy load.

ASTERISK-27299 #close
Reported-by: Aaron An
Tested-by: AaronAn

Change-Id: I870a072d73fd207463ac116ef97100addbc0820a
---
M res/res_rtp_asterisk.c
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  Corey Farrell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 51e509c..913fbad 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -3481,6 +3481,7 @@
 
 static void rtp_deallocate_transport(struct ast_rtp_instance *instance, struct ast_rtp *rtp)
 {
+	int saved_rtp_s = rtp->s;
 #ifdef HAVE_PJPROJECT
 	struct timeval wait = ast_tvadd(ast_tvnow(), ast_samp2tv(TURN_STATE_WAIT_TIME, 1000));
 	struct timespec ts = { .tv_sec = wait.tv_sec, .tv_nsec = wait.tv_usec * 1000, };
@@ -3498,7 +3499,9 @@
 
 	/* Destroy RTCP if it was being used */
 	if (rtp->rtcp && rtp->rtcp->s > -1) {
-		close(rtp->rtcp->s);
+		if (saved_rtp_s != rtp->rtcp->s) {
+			close(rtp->rtcp->s);
+		}
 		rtp->rtcp->s = -1;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/7668
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I870a072d73fd207463ac116ef97100addbc0820a
Gerrit-Change-Number: 7668
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Aaron An <anjb at ti-net.com.cn>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171220/aa69a704/attachment-0001.html>


More information about the asterisk-code-review mailing list