diff options
author | Aaron An <anjb@ti-net.com.cn> | 2017-12-18 20:14:11 +0800 |
---|---|---|
committer | Aaron An <anjb@ti-net.com.cn> | 2017-12-19 10:39:55 +0800 |
commit | 81474dfb23bae6bdf6a559951150766472c14d92 (patch) | |
tree | 8f0e759157f87b627f456c682a93c33e79234e59 /res/res_rtp_asterisk.c | |
parent | eb23919e69a309d44e86d529e094671fe55da6ca (diff) |
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
Diffstat (limited to 'res/res_rtp_asterisk.c')
-rw-r--r-- | res/res_rtp_asterisk.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index 51e509c77..913fbad1c 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -3481,6 +3481,7 @@ static int rtp_allocate_transport(struct ast_rtp_instance *instance, struct ast_ 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 @@ static void rtp_deallocate_transport(struct ast_rtp_instance *instance, struct a /* 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; } |