<p>Stanislav Abramenkov has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/20069">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjproject_bundled: Fixed deadlock between SIP transaction and dialog<br><br>ASTERISK-29286<br><br>Change-Id: Iac7972d8e0a4b10db88335dd170d818571fdc814<br>---<br>A third-party/pjproject/patches/0012-Fixed-deadlock-between-SIP-transaction-and-dialog.patch<br>1 file changed, 70 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/20069/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/pjproject/patches/0012-Fixed-deadlock-between-SIP-transaction-and-dialog.patch b/third-party/pjproject/patches/0012-Fixed-deadlock-between-SIP-transaction-and-dialog.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..769423c</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/patches/0012-Fixed-deadlock-between-SIP-transaction-and-dialog.patch</span><br><span>@@ -0,0 +1,59 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 72b46f74dd17b31815d4a0a19898bd2b425b45b3 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: sauwming <ming@teluu.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Fri, 14 Apr 2023 12:22:10 +0800</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH] Fixed deadlock between SIP transaction and dialog (#3492)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_transaction.c | 18 ++++++++++++------</span><br><span style="color: hsl(120, 100%, 40%);">+ 1 file changed, 12 insertions(+), 6 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c</span><br><span style="color: hsl(120, 100%, 40%);">+index 0c9f1b50f..87edf0a04 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_transaction.c</span><br><span>++++ b/pjsip/src/pjsip/sip_transaction.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -143,6 +143,7 @@ enum</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+     NO_NOTIFY = 1,</span><br><span style="color: hsl(120, 100%, 40%);">+     NO_SCHEDULE_HANDLER = 2,</span><br><span style="color: hsl(120, 100%, 40%);">++    RELEASE_LOCK = 4</span><br><span style="color: hsl(120, 100%, 40%);">+ };</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Prototypes. */</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1330,16 +1331,18 @@ static void tsx_set_state( pjsip_transaction *tsx,</span><br><span style="color: hsl(120, 100%, 40%);">+          * 3. tsx_shutdown() hasn't been called.</span><br><span style="color: hsl(120, 100%, 40%);">+          * Refer to ticket #2001 (https://github.com/pjsip/pjproject/issues/2001).</span><br><span style="color: hsl(120, 100%, 40%);">+          */</span><br><span style="color: hsl(120, 100%, 40%);">+-        if (event_src_type == PJSIP_EVENT_TIMER &&</span><br><span style="color: hsl(120, 100%, 40%);">+-            (pj_timer_entry *)event_src == &tsx->timeout_timer)</span><br><span style="color: hsl(120, 100%, 40%);">++        if ((flag & RELEASE_LOCK) != 0 ||</span><br><span style="color: hsl(120, 100%, 40%);">++            (event_src_type == PJSIP_EVENT_TIMER &&</span><br><span style="color: hsl(120, 100%, 40%);">++             (pj_timer_entry *)event_src == &tsx->timeout_timer))</span><br><span style="color: hsl(120, 100%, 40%);">+         {</span><br><span style="color: hsl(120, 100%, 40%);">+             pj_grp_lock_release(tsx->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+         (*tsx->tsx_user->on_tsx_state)(tsx, &e);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+-        if (event_src_type == PJSIP_EVENT_TIMER &&</span><br><span style="color: hsl(120, 100%, 40%);">+-            (pj_timer_entry *)event_src == &tsx->timeout_timer)</span><br><span style="color: hsl(120, 100%, 40%);">++        if ((flag & RELEASE_LOCK) != 0 ||</span><br><span style="color: hsl(120, 100%, 40%);">++            (event_src_type == PJSIP_EVENT_TIMER &&</span><br><span style="color: hsl(120, 100%, 40%);">++             (pj_timer_entry *)event_src == &tsx->timeout_timer))</span><br><span style="color: hsl(120, 100%, 40%);">+         {</span><br><span style="color: hsl(120, 100%, 40%);">+             pj_grp_lock_acquire(tsx->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -2044,9 +2047,12 @@ static void send_msg_callback( pjsip_send_state *send_state,</span><br><span style="color: hsl(120, 100%, 40%);">+             if (tsx->state != PJSIP_TSX_STATE_TERMINATED &&</span><br><span style="color: hsl(120, 100%, 40%);">+                 tsx->state != PJSIP_TSX_STATE_DESTROYED)</span><br><span style="color: hsl(120, 100%, 40%);">+             {</span><br><span style="color: hsl(120, 100%, 40%);">+-                tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED, </span><br><span style="color: hsl(120, 100%, 40%);">++                /* Set tsx state to TERMINATED, but release the lock</span><br><span style="color: hsl(120, 100%, 40%);">++                 * when invoking the callback, to avoid deadlock.</span><br><span style="color: hsl(120, 100%, 40%);">++                 */</span><br><span style="color: hsl(120, 100%, 40%);">++                tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,</span><br><span style="color: hsl(120, 100%, 40%);">+                                PJSIP_EVENT_TRANSPORT_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+-                               send_state->tdata, 0);</span><br><span style="color: hsl(120, 100%, 40%);">++                               send_state->tdata, RELEASE_LOCK);</span><br><span style="color: hsl(120, 100%, 40%);">+             } </span><br><span style="color: hsl(120, 100%, 40%);">+             /* Don't forget to destroy if we have pending destroy flag</span><br><span style="color: hsl(120, 100%, 40%);">+              * (https://github.com/pjsip/pjproject/issues/906)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/20069">change 20069</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/+/20069"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 20 </div>
<div style="display:none"> Gerrit-Change-Id: Iac7972d8e0a4b10db88335dd170d818571fdc814 </div>
<div style="display:none"> Gerrit-Change-Number: 20069 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Stanislav Abramenkov <stas.abramenkov@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>