<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1681/">https://reviewboard.asterisk.org/r/1681/</a>
</td>
</tr>
</table>
<br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By Mark Michelson.</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Asterisk has an issue where under certain circumstances, it may not properly shut down its RTP instance. The result of this is both a memory leak as well as a port leak. Eventually, the system will run out of ports in the RTP port range and will be pretty much unusable. The following conditions were necessary in order for this to occur:
1. RTP traffic had to be bridged through Asterisk, and not through the RTP engine's local or remote bridges. The reason this was necessary was so that Asterisk would send RTCP sender and receiver reports.
2. A transfer (blind or attended) had to be initiated using a REFER but without first sending a reINVITE to place a call on hold.
Circumstance (2) caused the response handler for our outbound NOTIFYs to take a different code path that would immediately cause the destruction of the SIP dialog without properly notifying the RTP engine to stop its workings. While certainly a bug, this wouldn't actually cause an issue unless Asterisk were sending RTCP. This is because Asterisk schedules RTCP transmission using the scheduler, which constantly has a reference to the RTP instance.
This patch does two things.
1. It takes the two sections for handling NOTIFY responses and puts it all inside handle_response_notify(). If any differences were present, I favored the inline code from handle_response() over what had previously been in handle_response_notify().
2. I added a new call to stop_media_flows() in the case where we have deferred a BYE due to a transfer. If we determine they are not going to send us a BYE like they are supposed to, we need to stop media so that the RTP will have its refcount decremented properly.
If anything is unclear, I can explain it in more detail.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I've tested transfers both from a Polycom phone and PJSUA. The Polycom sends a hold reINVITE before sending the REFER, and PJSUA does not. This allowed me to be sure that the updated code performed the same in both scenarios. I wasn't able to test the new addition of stop_media_flows() because all the UAs I test against are well behaved and send a BYE to us after sending a 200 OK for the NOTIFY we send.
A patch for 1.8.8.1 has been uploaded to ASTERISK-19192, but I have no feedback yet since it was only just uploaded.</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-19192">ASTERISK-19192</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/channels/chan_sip.c <span style="color: grey">(351501)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1681/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>