<p>Joshua Colp has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9821">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Reduce processing when a Contact is updated.<br><br>When a Contact is updated the only material change that qualify<br>support cares about is the underlying configuration for the AOR.<br>In this case we will update things with the new AOR information but<br>otherwise the callback to indicate the Contact has changed can be<br>ignored.<br><br>This is because it is only when a Contact is added or deleted that<br>material changes occur within the qualify support. An update can't<br>change the URI since it would result in a new Contact so it can be<br>ignored.<br><br>Change-Id: I2f97ebfa79969a36a97bb7b9afd5b6268cf1a07d<br>---<br>M res/res_pjsip/pjsip_options.c<br>1 file changed, 7 insertions(+), 57 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/21/9821/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c</span><br><span>index 5eaf9e8..3ef1e46 100644</span><br><span>--- a/res/res_pjsip/pjsip_options.c</span><br><span>+++ b/res/res_pjsip/pjsip_options.c</span><br><span>@@ -2064,7 +2064,7 @@</span><br><span> /*!</span><br><span> * \brief Check if the contact qualify options are different than local aor qualify options</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static int has_qualify_changed (struct ast_sip_contact *contact, struct sip_options_aor *aor_options)</span><br><span style="color: hsl(120, 100%, 40%);">+static int has_qualify_changed (const struct ast_sip_contact *contact, const struct sip_options_aor *aor_options)</span><br><span> {</span><br><span> if (!contact) {</span><br><span> return 0;</span><br><span>@@ -2185,77 +2185,27 @@</span><br><span> sip_options_contact_add_management_task, (void *) obj);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*!</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Task which updates a dynamic contact to an AOR</span><br><span style="color: hsl(0, 100%, 40%);">- * \note Run by aor_options->serializer</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static int sip_options_contact_update_task(void *obj)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct sip_options_contact_observer_task_data *task_data = obj;</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_sip_contact_status *contact_status;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- contact_status = ast_sip_get_contact_status(task_data->contact);</span><br><span style="color: hsl(0, 100%, 40%);">- if (contact_status) {</span><br><span style="color: hsl(0, 100%, 40%);">- switch (contact_status->status) {</span><br><span style="color: hsl(0, 100%, 40%);">- case CREATED:</span><br><span style="color: hsl(0, 100%, 40%);">- case UNAVAILABLE:</span><br><span style="color: hsl(0, 100%, 40%);">- case AVAILABLE:</span><br><span style="color: hsl(0, 100%, 40%);">- case UNKNOWN:</span><br><span style="color: hsl(0, 100%, 40%);">- /* Refresh the ContactStatus AMI events. */</span><br><span style="color: hsl(0, 100%, 40%);">- sip_options_contact_status_update(contact_status);</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">- case REMOVED:</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(contact_status, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(task_data->contact, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(task_data->aor_options, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free(task_data);</span><br><span style="color: hsl(0, 100%, 40%);">- return 0;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /*! \brief Observer callback invoked on contact update */</span><br><span> static void contact_observer_updated(const void *obj)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- struct sip_options_contact_observer_task_data *task_data;</span><br><span style="color: hsl(120, 100%, 40%);">+ const struct ast_sip_contact *contact = obj;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct sip_options_aor *aor_options = ao2_find(sip_options_aors, contact->aor, OBJ_SEARCH_KEY);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- task_data = ast_malloc(sizeof(*task_data));</span><br><span style="color: hsl(0, 100%, 40%);">- if (!task_data) {</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- task_data->contact = (struct ast_sip_contact *) obj;</span><br><span style="color: hsl(0, 100%, 40%);">- task_data->aor_options = ao2_find(sip_options_aors, task_data->contact->aor,</span><br><span style="color: hsl(0, 100%, 40%);">- OBJ_SEARCH_KEY);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (has_qualify_changed(task_data->contact, task_data->aor_options)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (has_qualify_changed(contact, aor_options)) {</span><br><span> struct ast_sip_aor *aor;</span><br><span> </span><br><span> aor = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "aor",</span><br><span style="color: hsl(0, 100%, 40%);">- task_data->contact->aor);</span><br><span style="color: hsl(120, 100%, 40%);">+ contact->aor);</span><br><span> if (aor) {</span><br><span> ast_debug(3, "AOR '%s' qualify options have been modified. Synchronize an AOR local state\n",</span><br><span style="color: hsl(0, 100%, 40%);">- task_data->contact->aor);</span><br><span style="color: hsl(120, 100%, 40%);">+ contact->aor);</span><br><span> ast_sip_push_task_wait_serializer(management_serializer,</span><br><span> sip_options_aor_observer_modified_task, aor);</span><br><span> ao2_ref(aor, -1);</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!task_data->aor_options) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free(task_data);</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(task_data->contact, +1);</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_sip_push_task(task_data->aor_options->serializer,</span><br><span style="color: hsl(0, 100%, 40%);">- sip_options_contact_update_task, task_data)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(task_data->contact, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(task_data->aor_options, -1);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free(task_data);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(aor_options);</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/9821">change 9821</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/9821"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I2f97ebfa79969a36a97bb7b9afd5b6268cf1a07d </div>
<div style="display:none"> Gerrit-Change-Number: 9821 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@digium.com> </div>