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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_refer: Move the progress dlg release to a serializer<br><br>Although the dlg session count was incremented in a pjsip servant<br>thread, there's no guarantee that the last thread to unref this<br>progress object was one.  Before we decrement, we need to make<br>sure that this is either a servant thread or that we push the<br>decrement to a serializer that is one.<br><br>Because pjsip_dlg_dec_session requires the dialog lock, we don't<br>want to wait on the task to complete if we had to push it to a<br>serializer.<br><br>Change-Id: I8ff2d5d94be3ff04298394070434e22a7d3cbc41<br>---<br>M res/res_pjsip_refer.c<br>1 file changed, 20 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c</span><br><span>index e8cfb96..d5c5787 100644</span><br><span>--- a/res/res_pjsip_refer.c</span><br><span>+++ b/res/res_pjsip_refer.c</span><br><span>@@ -340,6 +340,11 @@</span><br><span>         .on_evsub_state = refer_progress_on_evsub_state,</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int dlg_releaser_task(void *data) {</span><br><span style="color: hsl(120, 100%, 40%);">+        pjsip_dlg_dec_session((pjsip_dialog *)data, &refer_progress_module);</span><br><span style="color: hsl(120, 100%, 40%);">+      return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief Destructor for REFER progress sutrcture */</span><br><span> static void refer_progress_destroy(void *obj)</span><br><span> {</span><br><span>@@ -350,7 +355,21 @@</span><br><span>         }</span><br><span> </span><br><span>        if (progress->dlg) {</span><br><span style="color: hsl(0, 100%, 40%);">-         pjsip_dlg_dec_session(progress->dlg, &refer_progress_module);</span><br><span style="color: hsl(120, 100%, 40%);">+          /*</span><br><span style="color: hsl(120, 100%, 40%);">+             * Although the dlg session count was incremented in a pjsip servant</span><br><span style="color: hsl(120, 100%, 40%);">+           * thread, there's no guarantee that the last thread to unref this progress</span><br><span style="color: hsl(120, 100%, 40%);">+                * object was one.  Before we decrement, we need to make sure that this</span><br><span style="color: hsl(120, 100%, 40%);">+                * is either a servant thread or that we push the decrement to a</span><br><span style="color: hsl(120, 100%, 40%);">+               * serializer that is one.</span><br><span style="color: hsl(120, 100%, 40%);">+             *</span><br><span style="color: hsl(120, 100%, 40%);">+             * Because pjsip_dlg_dec_session requires the dialog lock, we don't want</span><br><span style="color: hsl(120, 100%, 40%);">+           * to wait on the task to complete if we had to push it to a serializer.</span><br><span style="color: hsl(120, 100%, 40%);">+               */</span><br><span style="color: hsl(120, 100%, 40%);">+           if (ast_sip_thread_is_servant()) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    pjsip_dlg_dec_session(progress->dlg, &refer_progress_module);</span><br><span style="color: hsl(120, 100%, 40%);">+          } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      ast_sip_push_task(NULL, dlg_releaser_task, progress->dlg);</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span>    }</span><br><span> </span><br><span>        ao2_cleanup(progress->transfer_data);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15555">change 15555</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/+/15555"/><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: I8ff2d5d94be3ff04298394070434e22a7d3cbc41 </div>
<div style="display:none"> Gerrit-Change-Number: 15555 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@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@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>