[asterisk-commits] kharwell: trunk r405749 - in /trunk: ./ res/res_pjsip/pjsip_options.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 16 14:07:01 CST 2014


Author: kharwell
Date: Thu Jan 16 14:06:59 2014
New Revision: 405749

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405749
Log:
res_pjsip: AOR option qualify_frequency not respected on startup

If an endpoint had previously dynamically registered a contact and the contact
information was successfully stored in astdb then upon restart the qualify
notifications would not be sent out if the qualify_frequency was set.  This was
due to the fact that only permanent contacts were being checked and scheduled
for qualifies on startup.  Modified the code to check and schedule all
registered contacts at startup.

(closes issue ASTERISK-23062)
Reported by: Rusty Newton
Review: https://reviewboard.asterisk.org/r/3124/
........

Merged revisions 405748 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip/pjsip_options.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/res/res_pjsip/pjsip_options.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/pjsip_options.c?view=diff&rev=405749&r1=405748&r2=405749
==============================================================================
--- trunk/res/res_pjsip/pjsip_options.c (original)
+++ trunk/res/res_pjsip/pjsip_options.c Thu Jan 16 14:06:59 2014
@@ -798,12 +798,12 @@
 
 /*!
  * \internal
- * \brief Qualify and schedule an endpoint's permanent contacts
+ * \brief Qualify and schedule an endpoint's contacts
  *
  * \detail For the given endpoint retrieve its list of aors, qualify all
- *         permanent contacts, and schedule for checks if configured.
- */
-static int qualify_and_schedule_permanent_cb(void *obj, void *arg, int flags)
+ *         contacts, and schedule for checks if configured.
+ */
+static int qualify_and_schedule_all_cb(void *obj, void *arg, int flags)
 {
 	struct ast_sip_endpoint *endpoint = obj;
 	char *aor_name, *aors;
@@ -817,31 +817,39 @@
 	while ((aor_name = strsep(&aors, ","))) {
 		RAII_VAR(struct ast_sip_aor *, aor,
 			 ast_sip_location_retrieve_aor(aor_name), ao2_cleanup);
-
-		if (!aor || !aor->permanent_contacts) {
+		struct ao2_container *contacts;
+
+		if (!aor || !(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
 			continue;
 		}
-		ao2_callback(aor->permanent_contacts, OBJ_NODATA, qualify_and_schedule_cb, aor);
-	}
-
-	return 0;
-}
-
-static void qualify_and_schedule_permanent(void)
-{
-	RAII_VAR(struct ao2_container *, endpoints,
-		 ast_sip_get_endpoints(), ao2_cleanup);
+
+		ao2_callback(contacts, OBJ_NODATA, qualify_and_schedule_cb, aor);
+		ao2_ref(contacts, -1);
+	}
+
+	return 0;
+}
+
+static void qualify_and_schedule_all(void)
+{
+	struct ao2_container *endpoints = ast_sip_get_endpoints();
+
+	if (!endpoints) {
+		return;
+	}
 
 	ao2_callback(endpoints, OBJ_NODATA,
-		     qualify_and_schedule_permanent_cb, NULL);
+		     qualify_and_schedule_all_cb, NULL);
+	ao2_ref(endpoints, -1);
 }
 
 int ast_res_pjsip_init_options_handling(int reload)
 {
 	const pj_str_t STR_OPTIONS = { "OPTIONS", 7 };
 
-	if (sched_qualifies) {
-		ao2_t_ref(sched_qualifies, -1, "Remove old scheduled qualifies");
+	if (reload) {
+		qualify_and_schedule_all();
+		return 0;
 	}
 
 	if (!(sched_qualifies = ao2_t_container_alloc(
@@ -851,11 +859,6 @@
 		return -1;
 	}
 
-	if (reload) {
-		qualify_and_schedule_permanent();
-		return 0;
-	}
-
 	if (pjsip_endpt_register_module(ast_sip_get_pjsip_endpoint(), &options_module) != PJ_SUCCESS) {
 		options_stop();
 		return -1;
@@ -871,7 +874,7 @@
 		return -1;
 	}
 
-	qualify_and_schedule_permanent();
+	qualify_and_schedule_all();
 	ast_cli_register_multiple(cli_options, ARRAY_LEN(cli_options));
 	ast_manager_register2("PJSIPQualify", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_sip_qualify, NULL, NULL, NULL);
 




More information about the asterisk-commits mailing list