[Asterisk-code-review] res_pjsip: delay contact pruning on Asterisk start (asterisk[19])

Friendly Automation asteriskteam at digium.com
Thu Jul 14 09:46:11 CDT 2022


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/18840 )

Change subject: res_pjsip: delay contact pruning on Asterisk start
......................................................................

res_pjsip: delay contact pruning on Asterisk start

Move the call to ast_sip_location_prune_boot_contacts() *after* the call
to ast_res_pjsip_init_options_handling() so that
res/res_pjsip/pjsip_options.c is informed about the contact deletion and
updates its sip_options_contact_statuses list. This allows for an AMI
event to be sent by res/res_pjsip/pjsip_options.c if the endpoint
registers again from the same remote address and port (i.e., same URI)
as used before the Asterisk restart.

ASTERISK-30109
Reported-by: Michael Neuhauser

Change-Id: I1ba4478019e4931a7085f62708d9b66837e901a8
---
M res/res_pjsip.c
M res/res_pjsip/pjsip_configuration.c
2 files changed, 8 insertions(+), 2 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index d722bbe..2febf3d 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -2766,6 +2766,14 @@
 		goto error;
 	}
 
+	/*
+	 * It is OK to prune the contacts now that
+	 * ast_res_pjsip_init_options_handling() has added the contact observer
+	 * of res/res_pjsip/pjsip_options.c to sorcery (to ensure that any
+	 * pruned contacts are removed from this module's data structure).
+	 */
+	ast_sip_location_prune_boot_contacts();
+
 	if (ast_res_pjsip_init_message_filter()) {
 		ast_log(LOG_ERROR, "Failed to initialize message IP updating. Aborting load\n");
 		goto error;
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 5f1f61e..6bc978d 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -2280,8 +2280,6 @@
 
 	load_all_endpoints();
 
-	ast_sip_location_prune_boot_contacts();
-
 	acl_change_sub = stasis_subscribe(ast_security_topic(), acl_change_stasis_cb, NULL);
 	stasis_subscription_accept_message_type(acl_change_sub, ast_named_acl_change_type());
 	stasis_subscription_set_filter(acl_change_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);

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

Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: I1ba4478019e4931a7085f62708d9b66837e901a8
Gerrit-Change-Number: 18840
Gerrit-PatchSet: 2
Gerrit-Owner: Michael Neuhauser <mike at firmix.at>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220714/4e5e2352/attachment-0001.html>


More information about the asterisk-code-review mailing list