<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7546">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip: Ignore state changes from old transactions.<br><br>When we fail over to a new target we create a new transaction<br>and it becomes the current INVITE transaction. This does not<br>prevent the previous transaction from raising state changes<br>and causing the session to be prematurely disconnected if a<br>transport error occurs immediately.<br><br>This change backports a fix from PJSIP that eliminates the<br>incorrect state change and reduces when they would be raised<br>in the first place.<br><br>ASTERISK-27408<br><br>Change-Id: Id22d087591782eee31311753d11e7eca4b95ef34<br>---<br>A third-party/pjproject/patches/0050-dont_terminate_session_early.patch<br>1 file changed, 71 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/third-party/pjproject/patches/0050-dont_terminate_session_early.patch b/third-party/pjproject/patches/0050-dont_terminate_session_early.patch<br>new file mode 100644<br>index 0000000..718968c<br>--- /dev/null<br>+++ b/third-party/pjproject/patches/0050-dont_terminate_session_early.patch<br>@@ -0,0 +1,71 @@<br>+commit ca0b723e92bd76bbda1bbd14477a829eaeeb675e<br>+Author: Joshua Colp <jcolp@digium.com><br>+Date:   Wed Dec 13 10:58:57 2017 +0000<br>+<br>+    Ignore transport error on completed transaction.<br>+    Don't disconnect call if transport error happens on transaction that is not initial INVITE transaction.<br>+    <br>+    Scenario:<br>+    <br>+    DNS lookup returning two servers.<br>+    Sending INVITE to first server over TCP.<br>+    Response received with code 503 (Service Unavailable).<br>+    Failover to second server, sending second INVITE after restarting the session.<br>+    TCP connection for the first INVITE getting disconnected and causing call disconnection (while second INVITE is still outstanding).<br>+    <br>+    This is a backport of 5714 from upstream PJSIP.<br>+<br>+diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c<br>+index ac4d1949..0173cb4c 100644<br>+--- a/pjsip/src/pjsip-ua/sip_inv.c<br>++++ b/pjsip/src/pjsip-ua/sip_inv.c<br>+@@ -4254,8 +4254,7 @@ static void inv_on_state_calling( pjsip_inv_session *inv, pjsip_event *e)<br>+    if ((tsx->status_code == PJSIP_SC_CALL_TSX_DOES_NOT_EXIST &&<br>+              tsx->method.id != PJSIP_CANCEL_METHOD) ||<br>+             tsx->status_code == PJSIP_SC_REQUEST_TIMEOUT ||<br>+-          tsx->status_code == PJSIP_SC_TSX_TIMEOUT ||<br>+-      tsx->status_code == PJSIP_SC_TSX_TRANSPORT_ERROR)<br>++        tsx->status_code == PJSIP_SC_TSX_TIMEOUT)<br>+     {<br>+        inv_set_cause(inv, tsx->status_code, &tsx->status_text);<br>+           inv_set_state(inv, PJSIP_INV_STATE_DISCONNECTED, e);<br>+diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c<br>+index 7ac3d1b7..d52b12a7 100644<br>+--- a/pjsip/src/pjsip/sip_transaction.c<br>++++ b/pjsip/src/pjsip/sip_transaction.c<br>+@@ -2044,9 +2044,14 @@ static void transport_callback(void *token, pjsip_tx_data *tdata,<br>+        */<br>+  lock_timer(tsx);<br>+     tsx->transport_err = (pj_status_t)-sent;<br>+- tsx_cancel_timer(tsx, &tsx->timeout_timer);<br>+-  tsx_schedule_timer(tsx, &tsx->timeout_timer, &delay,<br>+-                        TRANSPORT_ERR_TIMER);<br>++    /* Don't cancel timeout timer if tsx state is already<br>++    * PJSIP_TSX_STATE_COMPLETED (see #2076).<br>++    */<br>++ if (tsx->state < PJSIP_TSX_STATE_COMPLETED) {<br>++     tsx_cancel_timer(tsx, &tsx->timeout_timer);<br>++          tsx_schedule_timer(tsx, &tsx->timeout_timer, &delay,<br>++                        TRANSPORT_ERR_TIMER);<br>++        }<br>+    unlock_timer(tsx);<br>+    }<br>+ <br>+@@ -2077,9 +2082,14 @@ static void tsx_tp_state_callback( pjsip_transport *tp,<br>+       */<br>+  lock_timer(tsx);<br>+     tsx->transport_err = info->status;<br>+-    tsx_cancel_timer(tsx, &tsx->timeout_timer);<br>+-  tsx_schedule_timer(tsx, &tsx->timeout_timer, &delay,<br>+-                        TRANSPORT_ERR_TIMER);<br>++    /* Don't cancel timeout timer if tsx state is already<br>++    * PJSIP_TSX_STATE_COMPLETED (see #2076).<br>++    */<br>++ if (tsx->state < PJSIP_TSX_STATE_COMPLETED) {<br>++     tsx_cancel_timer(tsx, &tsx->timeout_timer);<br>++          tsx_schedule_timer(tsx, &tsx->timeout_timer, &delay,<br>++                        TRANSPORT_ERR_TIMER);<br>++        }<br>+    unlock_timer(tsx);<br>+     }<br>+ }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7546">change 7546</a>. To unsubscribe, 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/7546"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Id22d087591782eee31311753d11e7eca4b95ef34 </div>
<div style="display:none"> Gerrit-Change-Number: 7546 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>