<p>Alexei Gradinari has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18891">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_pubsub: destroy old subscriptions on RLS update using serializer<br><br>Set termination state to old subscriptions to immediately stop<br>sending NOTIFY messages on exten/device state changes.<br><br>Fix a data-race on RLS update.<br>While destroyinng old subscriptions, they can be used by exten/device state<br>changes. Thus, we need to add a task into serializer of subscription tree<br>to destroy old subscriptions.<br><br>ASTERISK-29906<br><br>Change-Id: I96582aad3a26515ca73a8460ee6756f56f6ba23b<br>---<br>M res/res_pjsip_pubsub.c<br>1 file changed, 20 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/91/18891/1</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 d0f3717..cd7724b 100644</span><br><span>--- a/res/res_pjsip_pubsub.c</span><br><span>+++ b/res/res_pjsip_pubsub.c</span><br><span>@@ -3994,6 +3994,16 @@</span><br><span>         return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int destroy_subscriptions_task(void *obj)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       struct ast_sip_subscription *sub = (struct ast_sip_subscription *) obj;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     shutdown_subscriptions(sub);</span><br><span style="color: hsl(120, 100%, 40%);">+  destroy_subscriptions(sub);</span><br><span style="color: hsl(120, 100%, 40%);">+</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> /*!</span><br><span>  * \brief Called whenever an in-dialog SUBSCRIBE is received</span><br><span>  *</span><br><span>@@ -4067,8 +4077,16 @@</span><br><span>                                                         AST_SCHED_DEL_UNREF(sched, sub_tree->notify_sched_id, ao2_ref(sub_tree, -1));</span><br><span>                                                     sub_tree->send_scheduled_notify = 0;</span><br><span>                                              }</span><br><span style="color: hsl(0, 100%, 40%);">-                                               shutdown_subscriptions(old_root);</span><br><span style="color: hsl(0, 100%, 40%);">-                                               destroy_subscriptions(old_root);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                                            /* Terminate old subscriptions to stop sending NOTIFY messages on exten/device state changes */</span><br><span style="color: hsl(120, 100%, 40%);">+                                               set_state_terminated(old_root);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                                             if (ast_sip_push_task(sub_tree->serializer, destroy_subscriptions_task, old_root)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                                       ast_log(LOG_ERROR, "Failed to push task to destroy old subscriptions for RLS '%s->%s'.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                                               ast_sorcery_object_get_id(endpoint), old_root->resource);</span><br><span style="color: hsl(120, 100%, 40%);">+                                                  /* If we can't push the destroy task, then just shutdown old subscriptions */</span><br><span style="color: hsl(120, 100%, 40%);">+                                                     shutdown_subscriptions(old_root);</span><br><span style="color: hsl(120, 100%, 40%);">+                                             }</span><br><span>                                    } else {</span><br><span>                                             destroy_subscriptions(new_root);</span><br><span>                                     }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18891">change 18891</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/+/18891"/><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: I96582aad3a26515ca73a8460ee6756f56f6ba23b </div>
<div style="display:none"> Gerrit-Change-Number: 18891 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>