https://issues.asterisk.org/jira/browse/ASTERISK-26518 commit 500470607eae4144b44ed4f188cfff437d56f0e7 Author: Alex Hermann Date: Fri Jan 20 11:09:01 2017 +0100 pjsip: Restore multihomed module Since the automatic dual stack commit, the multihome module has become part of the pjsip core module. This caused a circular dependency loop preventing the pjsip module from loading. By putting the logic back into its own module, things can be loaded again. diff --git a/res/res_pjsip.c b/res/res_pjsip.c index dd4a619d2a..6e9523d76b 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -4317,6 +4317,5 @@ static int unload_pjsip(void *data) if (ast_pjsip_endpoint && serializer_pool[0]) { ast_res_pjsip_cleanup_options_handling(); - ast_res_pjsip_cleanup_message_ip_updater(); ast_sip_destroy_distributor(); ast_res_pjsip_destroy_configuration(); ast_sip_destroy_system(); @@ -4488,11 +4487,6 @@ static int load_module(void) ast_res_pjsip_init_options_handling(0); - if (ast_res_pjsip_init_message_ip_updater()) { - ast_log(LOG_ERROR, "Failed to initialize message IP updating. Aborting load\n"); - goto error; - } - ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands)); AST_TEST_REGISTER(xml_sanitization_end_null); diff --git a/res/res_pjsip/pjsip_message_ip_updater.c b/res/res_pjsip_multihomed.c similarity index 94% rename from res/res_pjsip/pjsip_message_ip_updater.c rename to res/res_pjsip_multihomed.c index 7671ad0a75..3a29255973 100644 --- a/res/res_pjsip/pjsip_message_ip_updater.c +++ b/res/res_pjsip_multihomed.c @@ -16,6 +16,12 @@ * at the top of the source tree. */ +/*** MODULEINFO + pjproject + res_pjsip + core + ***/ + #include "asterisk.h" #include @@ -23,7 +29,8 @@ #include "asterisk/res_pjsip.h" #include "asterisk/res_pjsip_session.h" -#include "include/res_pjsip_private.h" +#include "res_pjsip/include/res_pjsip_private.h" +#include "asterisk/module.h" #define MOD_DATA_RESTRICTIONS "restrictions" @@ -273,31 +280,41 @@ static pj_status_t multihomed_on_tx_message(pjsip_tx_data *tdata) return PJ_SUCCESS; } -void ast_res_pjsip_cleanup_message_ip_updater(void) +static int unload_module(void) { ast_sip_unregister_service(&multihomed_module); ast_sip_unregister_supplement(&multihomed_supplement); ast_sip_session_unregister_supplement(&multihomed_session_supplement); + return 0; } -int ast_res_pjsip_init_message_ip_updater(void) +static int load_module(void) { + CHECK_PJSIP_MODULE_LOADED(); + if (ast_sip_session_register_supplement(&multihomed_session_supplement)) { ast_log(LOG_ERROR, "Could not register multihomed session supplement for outgoing requests\n"); - return -1; + return AST_MODULE_LOAD_FAILURE; } if (ast_sip_register_supplement(&multihomed_supplement)) { ast_log(LOG_ERROR, "Could not register multihomed supplement for outgoing requests\n"); - ast_res_pjsip_cleanup_message_ip_updater(); - return -1; + unload_module(); + return AST_MODULE_LOAD_FAILURE; } if (ast_sip_register_service(&multihomed_module)) { ast_log(LOG_ERROR, "Could not register multihomed module for incoming and outgoing requests\n"); - ast_res_pjsip_cleanup_message_ip_updater(); - return -1; + unload_module(); + return AST_MODULE_LOAD_FAILURE; } - return 0; + return AST_MODULE_LOAD_SUCCESS; } + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Multihomed Routing Support", + .support_level = AST_MODULE_SUPPORT_CORE, + .load = load_module, + .unload = unload_module, + .load_pri = AST_MODPRI_CHANNEL_DEPEND, +);