<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17996">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_pubsub: fix Batched Notifications stop working<br><br>If Subscription refresh occurred between when the batched notification<br>was scheduled and the serialized notification was to be sent,<br>then new schedule notification task would never be added.<br><br>There are 2 threads:<br><br>thread #1. ast_sip_subscription_notify is called,<br>if notification_batch_interval then call schedule_notification.<br>1.1. The schedule_notification checks notify_sched_id > -1<br>not true, then<br>send_scheduled_notify = 1<br>notify_sched_id =<br> ast_sched_add(sched, sub_tree->notification_batch_interval, sched_cb....<br>1.2. The sched_cb pushes task serialized_send_notify to serializer<br>and returns 0 which means no reschedule.<br>1.3. The serialized_send_notify checks send_scheduled_notify if it's false<br>the just returns. BUT notify_sched_id is still set, so no more ast_sched_add.<br><br>thread #2. pubsub_on_rx_refresh is called<br>2.1 it pushes serialized_pubsub_on_refresh_timeout to serializer<br>2.2. The serialized_pubsub_on_refresh_timeout calls pubsub_on_refresh_timeout<br>which calls send_notify<br>2.3. The send_notify set send_scheduled_notify = 0;<br><br>The serialized_send_notify should always unset notify_sched_id.<br><br>ASTERISK-29904 #close<br><br>Change-Id: Ifc50c00b213c396509e10326a1ed89d8cf8c7875<br>---<br>M res/res_pjsip_pubsub.c<br>1 file changed, 2 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c</span><br><span>index 60506db..dae3fef 100644</span><br><span>--- a/res/res_pjsip_pubsub.c</span><br><span>+++ b/res/res_pjsip_pubsub.c</span><br><span>@@ -2492,6 +2492,8 @@</span><br><span> </span><br><span> pjsip_dlg_inc_lock(dlg);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ sub_tree->notify_sched_id = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* It's possible that between when the notification was scheduled</span><br><span> * and now a new SUBSCRIBE arrived requiring full state to be</span><br><span> * sent out in an immediate NOTIFY. It's also possible that we're</span><br><span>@@ -2517,7 +2519,6 @@</span><br><span> ? "SUBSCRIPTION_TERMINATED" : "SUBSCRIPTION_STATE_CHANGED",</span><br><span> "Resource: %s", sub_tree->root->resource);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- sub_tree->notify_sched_id = -1;</span><br><span> pjsip_dlg_dec_lock(dlg);</span><br><span> ao2_cleanup(sub_tree);</span><br><span> return 0;</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17996">change 17996</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/+/17996"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: Ifc50c00b213c396509e10326a1ed89d8cf8c7875 </div>
<div style="display:none"> Gerrit-Change-Number: 17996 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </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>