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
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, };
/* 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;
}