<p>Kevin Harwell <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/7489">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Kevin Harwell: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip_options: contacts sometimes not being updated on reload<br><br>For both dynamic and static contacts it was possible that potential AOR<br>changes were not being applied to all contacts. This was because the qualify<br>and schedule code was only retrieving AOR's, and contacts with frequencies<br>greater than zero.<br><br>For instance the following could happen: and AOR/contact has a frequency of 5,<br>it then gets set to 0, and then a reload occurs. All scheduled OPTIONS are<br>stopped, a list of AOR's is retrieved with frequency > 0, but none are<br>selected since in this scenario all are 0. The contact for the one previously<br>set to 5 though does not get updated, so it's status remains "AVAILABLE".<br><br>This patch makes it so all contacts (static and dynamic) are selected, and<br>appropriately updated if need be.<br><br>ASTERISK-27467 #close<br><br>Change-Id: I7a920170f89c683af9505d4723a44fc6841decdb<br>---<br>M res/res_pjsip/pjsip_options.c<br>1 file changed, 10 insertions(+), 24 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c<br>index 662166c..ab7aa40 100644<br>--- a/res/res_pjsip/pjsip_options.c<br>+++ b/res/res_pjsip/pjsip_options.c<br>@@ -1175,32 +1175,21 @@<br> return 0;<br> }<br> <br>-/*!<br>- * \internal<br>- * \brief Unschedule all existing contacts<br>- */<br>-static int unschedule_all_cb(void *obj, void *arg, int flags)<br>-{<br>- struct sched_data *data = obj;<br>-<br>- AST_SCHED_DEL_UNREF(sched, data->id, ao2_ref(data, -1));<br>-<br>- return CMP_MATCH;<br>-}<br>-<br> static void qualify_and_schedule_all(void)<br> {<br>- struct ast_variable *var = ast_variable_new("qualify_frequency >", "0", "");<br> struct ao2_container *aors;<br> struct ao2_container *contacts;<br> <br>- if (!var) {<br>- return;<br>- }<br>- aors = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(),<br>- "aor", AST_RETRIEVE_FLAG_MULTIPLE, var);<br>+ /*<br>+ * It's possible that the AOR had some of it's fields updated prior to a<br>+ * reload. For instance qualifying could have been turned on or off by<br>+ * setting the qualify_frequency. Due to this we have to iterate through<br>+ * all contacts (static and dynamic), and not just ones where the frequency<br>+ * is greater than zero, updating any contact fields with the AOR's values.<br>+ */<br> <br>- ao2_callback(sched_qualifies, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, unschedule_all_cb, NULL);<br>+ aors = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(),<br>+ "aor", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);<br> <br> if (aors) {<br> ao2_callback(aors, OBJ_NODATA, qualify_and_schedule_all_cb, NULL);<br>@@ -1208,14 +1197,11 @@<br> }<br> <br> contacts = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(),<br>- "contact", AST_RETRIEVE_FLAG_MULTIPLE, var);<br>+ "contact", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);<br> if (contacts) {<br> ao2_callback(contacts, OBJ_NODATA, qualify_and_schedule_cb_without_aor, NULL);<br> ao2_ref(contacts, -1);<br> }<br>-<br>- ast_variables_destroy(var);<br>-<br> }<br> <br> int ast_sip_format_contact_ami(void *obj, void *arg, int flags)<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7489">change 7489</a>. To unsubscribe, 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/7489"/><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-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I7a920170f89c683af9505d4723a44fc6841decdb </div>
<div style="display:none"> Gerrit-Change-Number: 7489 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>