[asterisk-commits] Revert "Update qualifies when AOR configuration changes." (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 8 12:08:50 CST 2017


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/4904 )

Change subject: Revert "Update qualifies when AOR configuration changes."
......................................................................


Revert "Update qualifies when AOR configuration changes."

This reverts commit 6492e91392b8fd394193e411c6eb64b45486093f.

The change in question was intended to prevent the need to reload in
order to update qualifies on contacts when an AOR changes. However, this
ended up causing a deadlock instead.

Change-Id: I1a835c90a5bb65b6dc3a1e94cddc12a4afc3d71e
---
M res/res_pjsip.c
M res/res_pjsip/include/res_pjsip_private.h
M res/res_pjsip/location.c
M res/res_pjsip/pjsip_options.c
M res/res_pjsip_registrar.c
5 files changed, 10 insertions(+), 58 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Anonymous Coward #1000019: Verified



diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 347c579..59777c9 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -4382,6 +4382,7 @@
 static int reload_configuration_task(void *obj)
 {
 	ast_res_pjsip_reload_configuration();
+	ast_res_pjsip_init_options_handling(1);
 	ast_sip_initialize_dns();
 	return 0;
 }
diff --git a/res/res_pjsip/include/res_pjsip_private.h b/res/res_pjsip/include/res_pjsip_private.h
index 6ddbd1f..0bdb633 100644
--- a/res/res_pjsip/include/res_pjsip_private.h
+++ b/res/res_pjsip/include/res_pjsip_private.h
@@ -184,18 +184,6 @@
 int ast_res_pjsip_init_options_handling(int reload);
 
 /*!
- * \internal
- * \brief Indicate OPTIONS handling for this AOR needs updating.
- *
- * When AOR configuration is retrieved, it is possible that the
- * qualify frequency has changed. The OPTIONs code needs to update
- * its qualifies to reflect these changes.
- *
- * \param aor The AOR that has been retrieved
- */
-void ast_res_pjsip_update_options(struct ast_sip_aor *aor);
-
-/*!
  * \internal Initialize message IP updating handling.
  *
  * \retval 0 on success
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index cfe65b1..5abfcab 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -1137,12 +1137,6 @@
 	return status ? 0 : -1;
 }
 
-static int aor_apply_handler(const struct ast_sorcery *sorcery, void *object)
-{
-	ast_res_pjsip_update_options(object);
-	return 0;
-}
-
 /*! \brief Initialize sorcery with location support */
 int ast_sip_initialize_sorcery_location(void)
 {
@@ -1159,7 +1153,7 @@
 	ast_sorcery_apply_default(sorcery, "aor", "config", "pjsip.conf,criteria=type=aor");
 
 	if (ast_sorcery_object_register(sorcery, "contact", contact_alloc, NULL, contact_apply_handler) ||
-		ast_sorcery_object_register(sorcery, "aor", aor_alloc, NULL, aor_apply_handler)) {
+		ast_sorcery_object_register(sorcery, "aor", aor_alloc, NULL, NULL)) {
 		return -1;
 	}
 
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 51987f4..6fd3c25 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -518,18 +518,6 @@
 static int qualify_contact_sched(const void *obj)
 {
 	struct sched_data *data = (struct sched_data *) obj;
-	struct ast_sip_aor *aor;
-
-	/* This helps us to determine if an AOR has been removed
-	 * from configuration, and if so, stop qualifying the
-	 * contact
-	 */
-	aor = ast_sip_location_retrieve_aor(data->contact->aor);
-	if (!aor) {
-		ao2_ref(data, -1);
-		return 0;
-	}
-	ao2_ref(aor, -1);
 
 	ao2_ref(data->contact, +1);
 	if (ast_sip_push_task(NULL, qualify_contact_task, data->contact)) {
@@ -1176,10 +1164,12 @@
 	struct ast_sip_aor *aor = obj;
 	struct ao2_container *contacts;
 
-	contacts = ast_sip_location_retrieve_aor_contacts(aor);
-	if (contacts) {
-		ao2_callback(contacts, OBJ_NODATA, qualify_and_schedule_cb_with_aor, aor);
-		ao2_ref(contacts, -1);
+	if (aor->permanent_contacts) {
+		contacts = ast_sip_location_retrieve_aor_contacts(aor);
+		if (contacts) {
+			ao2_callback(contacts, OBJ_NODATA, qualify_and_schedule_cb_with_aor, aor);
+			ao2_ref(contacts, -1);
+		}
 	}
 
 	return 0;
@@ -1504,29 +1494,6 @@
 	qualify_and_schedule_all();
 
 	return 0;
-}
-
-static int unschedule_for_aor_cb(void *obj, void *arg, int flags)
-{
-	struct sched_data *data = obj;
-	struct ast_sip_aor *aor = arg;
-
-	if (!strcmp(ast_sorcery_object_get_id(aor), data->contact->aor)) {
-		AST_SCHED_DEL_UNREF(sched, data->id, ao2_ref(data, -1));
-	}
-
-	return 0;
-}
-
-void ast_res_pjsip_update_options(struct ast_sip_aor *aor)
-{
-	/* This can happen if an AOR is created and applied before OPTIONs code has been initialized */
-	if (!sched_qualifies) {
-		return;
-	}
-
-	ao2_callback(sched_qualifies, OBJ_NODATA | OBJ_UNLINK, unschedule_for_aor_cb, aor);
-	qualify_and_schedule_all_cb(aor, NULL, 0);
 }
 
 void ast_res_pjsip_cleanup_options_handling(void)
diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c
index d190487..2db7538 100644
--- a/res/res_pjsip_registrar.c
+++ b/res/res_pjsip_registrar.c
@@ -456,6 +456,8 @@
 			}
 
 			contact_update->expiration_time = ast_tvadd(ast_tvnow(), ast_samp2tv(expiration, 1));
+			contact_update->qualify_frequency = aor->qualify_frequency;
+			contact_update->authenticate_qualify = aor->authenticate_qualify;
 			if (path_str) {
 				ast_string_field_set(contact_update, path, ast_str_buffer(path_str));
 			}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1a835c90a5bb65b6dc3a1e94cddc12a4afc3d71e
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>



More information about the asterisk-commits mailing list