]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: delay contact pruning on Asterisk start
authorMichael Neuhauser <mike@firmix.at>
Tue, 14 Jun 2022 09:12:47 +0000 (11:12 +0200)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Thu, 14 Jul 2022 14:44:22 +0000 (09:44 -0500)
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

res/res_pjsip.c
res/res_pjsip/pjsip_configuration.c

index c910551912753c0d4793dd587aabd45af8efad6c..08d6acd9ab89ced874baf4f7704982c4fc476b90 100644 (file)
@@ -2670,6 +2670,14 @@ static int load_module(void)
                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;
index 72d2d1779edc7bc48beb2922921ef75124a21ed5..b514cea0a2bd351509a90afcb9822d44ce8bef42 100644 (file)
@@ -2095,8 +2095,6 @@ int ast_res_pjsip_initialize_configuration(void)
 
        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);