<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15424">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_refer: Always serialize calls to refer_progress_notify<br><br>refer_progress_notify wasn't always being called from the progress<br>serializer. This could allow clearing notification->progress->sub<br>in one thread while another was trying to use it.<br><br>* Instances where refer_progress_notify was being called in-line,<br> have been changed to use ast_sip_push_task().<br><br>Change-Id: Idcf1934c4e873f2c82e2d106f8d9f040caf9fa1e<br>---<br>M res/res_pjsip_refer.c<br>1 file changed, 26 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/24/15424/1</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 06ea0b6..17625cc 100644</span><br><span>--- a/res/res_pjsip_refer.c</span><br><span>+++ b/res/res_pjsip_refer.c</span><br><span>@@ -127,10 +127,14 @@</span><br><span> * but we are already running a task... thus it would deadlock */</span><br><span> if (notification->state == PJSIP_EVSUB_STATE_TERMINATED) {</span><br><span> ast_debug(3, "Subscription '%p' is being terminated as a result of a NOTIFY, removing REFER progress structure early on progress monitor '%p'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- notification->progress->sub, notification->progress);</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_dlg_inc_lock(notification->progress->dlg);</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_evsub_set_mod_data(notification->progress->sub, refer_progress_module.id, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_dlg_dec_lock(notification->progress->dlg);</span><br><span style="color: hsl(120, 100%, 40%);">+ sub, notification->progress);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!notification->progress->sub) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Subscription %p was stepped on!", sub);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_dlg_inc_lock(notification->progress->dlg);</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_evsub_set_mod_data(notification->progress->sub, refer_progress_module.id, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_dlg_dec_lock(notification->progress->dlg);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> /* This is for dropping the reference on the subscription */</span><br><span> ao2_cleanup(notification->progress);</span><br><span>@@ -560,7 +564,9 @@</span><br><span> notification = refer_progress_notification_alloc(attended->progress, response,</span><br><span> PJSIP_EVSUB_STATE_TERMINATED);</span><br><span> if (notification) {</span><br><span style="color: hsl(0, 100%, 40%);">- refer_progress_notify(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sip_push_task(attended->progress->serializer, refer_progress_notify, notification)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -616,7 +622,9 @@</span><br><span> PJSIP_EVSUB_STATE_TERMINATED);</span><br><span> </span><br><span> if (notification) {</span><br><span style="color: hsl(0, 100%, 40%);">- refer_progress_notify(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sip_push_task(refer->progress->serializer, refer_progress_notify, notification)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> } else if (refer->progress) {</span><br><span> /* If attended transfer and progress monitoring is being done attach a frame hook so we can monitor it */</span><br><span>@@ -637,7 +645,9 @@</span><br><span> ast_channel_name(chan));</span><br><span> </span><br><span> if (notification) {</span><br><span style="color: hsl(0, 100%, 40%);">- refer_progress_notify(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sip_push_task(refer->progress->serializer, refer_progress_notify, notification)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -660,7 +670,9 @@</span><br><span> ast_channel_name(chan));</span><br><span> </span><br><span> if (notification) {</span><br><span style="color: hsl(0, 100%, 40%);">- refer_progress_notify(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sip_push_task(refer->progress->serializer, refer_progress_notify, notification)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> ao2_cleanup(refer->progress);</span><br><span>@@ -680,7 +692,9 @@</span><br><span> ast_channel_name(chan));</span><br><span> </span><br><span> if (notification) {</span><br><span style="color: hsl(0, 100%, 40%);">- refer_progress_notify(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sip_push_task(refer->progress->serializer, refer_progress_notify, notification)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> ast_channel_lock(chan);</span><br><span>@@ -1155,7 +1169,9 @@</span><br><span> </span><br><span> if (notification) {</span><br><span> /* The refer_progress_notify function will call ao2_cleanup on this for us */</span><br><span style="color: hsl(0, 100%, 40%);">- refer_progress_notify(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sip_push_task(progress->serializer, refer_progress_notify, notification)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(notification);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15424">change 15424</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/+/15424"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Idcf1934c4e873f2c82e2d106f8d9f040caf9fa1e </div>
<div style="display:none"> Gerrit-Change-Number: 15424 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>