<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13174">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: initialize pending's topology to endpoint's<br><br>Found during some testing, there is a race condition between selecting an<br>appropriate bridge type for a call versus the applying of media on the callee's<br>session. In some instances a native bridge type would have been chosen, but<br>due to the callee's media not yet being established at bridge compatibility<br>check time the simple bridge type is picked instead.<br><br>When using chan_pjsip this initiates a topology change event. The topologies<br>are then compared for the two sessions. However, when the topology was created<br>for the caller its streams are initialized to "inactive". This topology is then<br>used as a base when creating the callee's topology, and streams. Soon after<br>the caller's topology's stream(s) get updated based on the sdp (get set to<br>sendrecv in the failing scenario).<br><br>Now when the topology change event is raised, and the two topologies are<br>compared, the comparison fails due to a stream state mismatch (sendrecv vs<br>inactive). And since they differ a reinvite is sent out (to the caller in<br>this case).<br><br>This patch makes it such that when the caller's topology is initially created<br>it gets created based on its configured endpoint's media topology. When the<br>endpoint's topology is created its stream's state(s) are initialized to<br>sendrecv instead of inactive. Subsequently, now when the callee's topology is<br>created its topology streams are now initialized to sendrecv. Thus when the<br>topology change event occurs due to the mentioned scenario the stream states<br>match for the given sessions, and the reinvite is not sent unless due to some<br>other valid mismatch.<br><br>Note, this patch only changes one pending media state's creation point. It's<br>possible other places *could* be changed, however for now it was deemed best<br>to only alter what's here.<br><br>Change-Id: I6ba3a6a75f64824a1b963044c37acbe951c389c7<br>---<br>M res/res_pjsip_session.c<br>1 file changed, 1 insertion(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index dc476ff..44c2581 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -712,7 +712,7 @@</span><br><span> </span><br><span>         /* It is possible for SDP deferral to have already created a pending topology */</span><br><span>     if (!session->pending_media_state->topology) {</span><br><span style="color: hsl(0, 100%, 40%);">-            session->pending_media_state->topology = ast_stream_topology_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+           session->pending_media_state->topology = ast_stream_topology_clone(session->endpoint->media.topology);</span><br><span>           if (!session->pending_media_state->topology) {</span><br><span>                         return -1;</span><br><span>           }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13174">change 13174</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13174"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I6ba3a6a75f64824a1b963044c37acbe951c389c7 </div>
<div style="display:none"> Gerrit-Change-Number: 13174 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>