[Asterisk-code-review] pjsip options: handle modification of qualify options in rea... (asterisk[13])

Joshua Colp asteriskteam at digium.com
Wed Jun 6 11:21:39 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9033 )

Change subject: pjsip_options: handle modification of qualify options in realtime
......................................................................

pjsip_options: handle modification of qualify options in realtime

Currentrly pjsip_options code does not handle the situation when the
qualify options were changed in realtime database.
Only 'module reload res_pjsip' helps.

This patch add a check on contact add/update observers if the contact
qualify options are different than local aor qualify options.
If the qualify options were modified then synchronize
the pjsip_options AOR local state.

ASTERISK-27872

Change-Id: Id55210a18e62ed5d35a88e408d5fe84a3c513c62
---
M res/res_pjsip/pjsip_options.c
1 file changed, 45 insertions(+), 9 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved



diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index d05d7bd..055cb4f 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -2059,6 +2059,29 @@
 	struct ast_sip_contact *contact;
 };
 
+
+/*!
+ * \brief Check if the contact qualify options are different than local aor qualify options
+ */
+static int has_qualify_changed (struct ast_sip_contact *contact, struct sip_options_aor *aor_options)
+{
+	if (!contact) {
+	    return 0;
+	}
+
+	if (!aor_options) {
+		if (contact->qualify_frequency) {
+			return 1;
+		}
+	} else if (contact->qualify_frequency != aor_options->qualify_frequency
+		|| contact->authenticate_qualify != aor_options->authenticate_qualify
+		|| ((int)(contact->qualify_timeout * 1000)) != ((int)(aor_options->qualify_timeout * 1000))) {
+		return 1;
+	}
+
+	return 0;
+}
+
 /*!
  * \brief Task which adds a dynamic contact to an AOR
  * \note Run by aor_options->serializer
@@ -2135,23 +2158,21 @@
 	task_data.contact = obj;
 	task_data.aor_options = ao2_find(sip_options_aors, task_data.contact->aor,
 		OBJ_SEARCH_KEY);
-	if (!task_data.aor_options) {
+
+	if (has_qualify_changed(task_data.contact, task_data.aor_options)) {
 		struct ast_sip_aor *aor;
 
-		/*
-		 * The only reason this would occur is if the AOR was sourced
-		 * after the last reload happened.  To handle this we fetch the
-		 * AOR and treat it as if we received notification that it had
-		 * been created.  This will create the needed AOR feeder
-		 * compositor and will cause any associated contact statuses and
-		 * endpoint state compositors to also get created if needed.
-		 */
 		aor = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "aor",
 			task_data.contact->aor);
 		if (aor) {
+			ast_debug(3, "AOR '%s' qualify options have been modified. Synchronize an AOR local state\n",
+				task_data.contact->aor);
 			sip_options_aor_observer_modified_task(aor);
 			ao2_ref(aor, -1);
 		}
+	}
+
+	if (!task_data.aor_options) {
 		return 0;
 	}
 
@@ -2215,6 +2236,21 @@
 	task_data->contact = (struct ast_sip_contact *) obj;
 	task_data->aor_options = ao2_find(sip_options_aors, task_data->contact->aor,
 		OBJ_SEARCH_KEY);
+
+	if (has_qualify_changed(task_data->contact, task_data->aor_options)) {
+		struct ast_sip_aor *aor;
+
+		aor = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "aor",
+			task_data->contact->aor);
+		if (aor) {
+			ast_debug(3, "AOR '%s' qualify options have been modified. Synchronize an AOR local state\n",
+				task_data->contact->aor);
+			ast_sip_push_task_wait_serializer(management_serializer,
+				sip_options_aor_observer_modified_task, aor);
+			ao2_ref(aor, -1);
+		}
+	}
+
 	if (!task_data->aor_options) {
 		ast_free(task_data);
 		return;

-- 
To view, visit https://gerrit.asterisk.org/9033
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Id55210a18e62ed5d35a88e408d5fe84a3c513c62
Gerrit-Change-Number: 9033
Gerrit-PatchSet: 3
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180606/14307ccc/attachment.html>


More information about the asterisk-code-review mailing list