diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 92390160dd129811e6c8ef4d5261f00b5c071db5..fde6479e99be1978b2cecba9c7943def11d22d51 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -4338,6 +4338,7 @@ AST_TEST_DEFINE(xml_sanitization_exceeds_buffer) 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 8ba2528b240687ec1660c4c7cf5b24a56d52a9dd..11ad12c455691468bf6dfeea5a28630071edb9bd 100644 --- a/res/res_pjsip/include/res_pjsip_private.h +++ b/res/res_pjsip/include/res_pjsip_private.h @@ -183,18 +183,6 @@ void ast_sip_destroy_global_headers(void); */ 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. * diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c index 9ab6e5665225ee9405fa6d91504c59db53b7e42b..d8f0c58b5c901c632fe0e757b2a4f5df3188bf73 100644 --- a/res/res_pjsip/location.c +++ b/res/res_pjsip/location.c @@ -1144,12 +1144,6 @@ static int contact_apply_handler(const struct ast_sorcery *sorcery, void *object 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) { @@ -1166,7 +1160,7 @@ int ast_sip_initialize_sorcery_location(void) 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 1e474ef14014a1c0987b4834f0c4229da8de3940..698203fac3c4d25e1ae7c569afca5f09344024aa 100644 --- a/res/res_pjsip/pjsip_options.c +++ b/res/res_pjsip/pjsip_options.c @@ -528,18 +528,6 @@ static int qualify_contact_task(void *obj) 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)) { @@ -1185,10 +1173,12 @@ static int qualify_and_schedule_all_cb(void *obj, void *arg, int flags) 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; @@ -1515,29 +1505,6 @@ int ast_res_pjsip_init_options_handling(int reload) 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) { ast_cli_unregister_multiple(cli_options, ARRAY_LEN(cli_options)); diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c index dc3dfcf152edfa708f02dbde56e907f212403d04..d54bffa0c7458d6588c6c03c8b5872e0f0390c4a 100644 --- a/res/res_pjsip_registrar.c +++ b/res/res_pjsip_registrar.c @@ -456,6 +456,8 @@ static int register_aor_core(pjsip_rx_data *rdata, } 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)); }