[Asterisk-code-review] pjsip_options.c: Allow immediate qualifies for new contacts. (...asterisk[16])

Joshua Colp asteriskteam at digium.com
Mon May 13 14:14:45 CDT 2019


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

Change subject: pjsip_options.c: Allow immediate qualifies for new contacts.
......................................................................

pjsip_options.c: Allow immediate qualifies for new contacts.

When multiple endpoints try to register close together using the same
AOR with qualify_frequency set, one contact would qualify immediately
while the other contacts would have to wait out the duration of the
timer before being able to qualify. Changing the conditional to check
the contact container count for a non-zero value allows all contacts to
qualify immediately.

Change-Id: I79478118ee7e0d6e76af7c354d66684220db9415
---
M res/res_pjsip/pjsip_options.c
1 file changed, 24 insertions(+), 23 deletions(-)

Approvals:
  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 a7aefaa..2c30580 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -2100,30 +2100,31 @@
 	ao2_cleanup(contact_status);
 
 	if (task_data->aor_options->qualify_frequency) {
-		/* If this is the first contact we need to schedule up qualification */
-		if (ao2_container_count(task_data->aor_options->contacts) == 1) {
-			ast_debug(3, "Starting scheduled callback on AOR '%s' for qualifying as there is now a contact on it\n",
+		/* There will always be a contact here, and we need to immediately schedule
+		 * a qualify so that contacts are not waiting for the qualify_frequency
+		 * timer duration before qualifying.
+		 */
+		ast_debug(3, "Starting scheduled callback on AOR '%s' for qualifying as there is now a contact on it\n",
+			task_data->aor_options->name);
+		/*
+		 * We immediately schedule the initial qualify so that we get
+		 * reachable/unreachable as soon as possible.  Realistically
+		 * since they pretty much just registered they should be
+		 * reachable.
+		 */
+		if (task_data->aor_options->sched_task) {
+			ast_sip_sched_task_cancel(task_data->aor_options->sched_task);
+			ao2_ref(task_data->aor_options->sched_task, -1);
+			task_data->aor_options->sched_task = NULL;
+		}
+		task_data->aor_options->sched_task = ast_sip_schedule_task(
+			task_data->aor_options->serializer, 1, sip_options_qualify_aor,
+			ast_taskprocessor_name(task_data->aor_options->serializer),
+			task_data->aor_options,
+			AST_SIP_SCHED_TASK_VARIABLE | AST_SIP_SCHED_TASK_DATA_AO2);
+		if (!task_data->aor_options->sched_task) {
+			ast_log(LOG_ERROR, "Unable to schedule qualify for contacts of AOR '%s'\n",
 				task_data->aor_options->name);
-			/*
-			 * We immediately schedule the initial qualify so that we get
-			 * reachable/unreachable as soon as possible.  Realistically
-			 * since they pretty much just registered they should be
-			 * reachable.
-			 */
-			if (task_data->aor_options->sched_task) {
-				ast_sip_sched_task_cancel(task_data->aor_options->sched_task);
-				ao2_ref(task_data->aor_options->sched_task, -1);
-				task_data->aor_options->sched_task = NULL;
-			}
-			task_data->aor_options->sched_task = ast_sip_schedule_task(
-				task_data->aor_options->serializer, 1, sip_options_qualify_aor,
-				ast_taskprocessor_name(task_data->aor_options->serializer),
-				task_data->aor_options,
-				AST_SIP_SCHED_TASK_VARIABLE | AST_SIP_SCHED_TASK_DATA_AO2);
-			if (!task_data->aor_options->sched_task) {
-				ast_log(LOG_ERROR, "Unable to schedule qualify for contacts of AOR '%s'\n",
-					task_data->aor_options->name);
-			}
 		}
 	} else {
 		/*

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11361
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I79478118ee7e0d6e76af7c354d66684220db9415
Gerrit-Change-Number: 11361
Gerrit-PatchSet: 2
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190513/2237251c/attachment.html>


More information about the asterisk-code-review mailing list