diff --git a/res/res_pjsip.c b/res/res_pjsip.c index aa6a500cdc38afea7032539c8bb7173ebe6017d0..e5af28ca8211f772f1f2b5504921e225386f65f8 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -3520,14 +3520,21 @@ static int reload_module(void) static int unload_pjsip(void *data) { ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands)); + ast_res_pjsip_cleanup_options_handling(); + internal_sip_destroy_outbound_authentication(); + ast_sip_destroy_distributor(); + ast_res_pjsip_destroy_configuration(); + ast_sip_destroy_system(); + ast_sip_destroy_global_headers(); + internal_sip_unregister_service(&supplement_module); + if (monitor_thread) { + stop_monitor_thread(); + } if (memory_pool) { pj_pool_release(memory_pool); memory_pool = NULL; } - if (ast_pjsip_endpoint) { - pjsip_endpt_destroy(ast_pjsip_endpoint); - ast_pjsip_endpoint = NULL; - } + ast_pjsip_endpoint = NULL; pj_caching_pool_destroy(&caching_pool); pj_shutdown(); return 0; @@ -3535,16 +3542,6 @@ static int unload_pjsip(void *data) static int unload_module(void) { - ast_res_pjsip_cleanup_options_handling(); - internal_sip_destroy_outbound_authentication(); - ast_sip_destroy_distributor(); - ast_res_pjsip_destroy_configuration(); - ast_sip_destroy_system(); - ast_sip_destroy_global_headers(); - internal_sip_unregister_service(&supplement_module); - if (monitor_thread) { - stop_monitor_thread(); - } /* The thread this is called from cannot call PJSIP/PJLIB functions, * so we have to push the work to the threadpool to handle */ diff --git a/res/res_pjsip_keepalive.c b/res/res_pjsip_keepalive.c index 5e9d168eacc87baff2bbc73207d502fbfda0fd79..b854fc957ef96dc011b1147e3b87d07b8b35e4c4 100644 --- a/res/res_pjsip_keepalive.c +++ b/res/res_pjsip_keepalive.c @@ -244,7 +244,7 @@ static int load_module(void) ast_sorcery_observer_add(ast_sip_get_sorcery(), "global", &keepalive_global_observer); ast_sorcery_reload_object(ast_sip_get_sorcery(), "global"); - ast_module_ref(ast_module_info->self); + ast_module_shutdown_ref(ast_module_info->self); return AST_MODULE_LOAD_SUCCESS; } diff --git a/res/res_pjsip_notify.c b/res/res_pjsip_notify.c index d7e3d803b76231d022b07f5990d7af455e652006..e494daf26fd5509a15cad35a8197c3d3757b0b0c 100644 --- a/res/res_pjsip_notify.c +++ b/res/res_pjsip_notify.c @@ -1021,6 +1021,7 @@ static int unload_module(void) ast_manager_unregister("PJSIPNotify"); ast_cli_unregister_multiple(cli_options, ARRAY_LEN(cli_options)); aco_info_destroy(¬ify_cfg); + ao2_global_obj_release(globals); return 0; } diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index 4d53091b9b2570e360ffa84644d05a79edbbab9f..e7b4b02ec6a60ae752a15c14794c19451590e2d6 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -4286,6 +4286,7 @@ static int unload_module(void) ast_manager_unregister(AMI_SHOW_SUBSCRIPTIONS_INBOUND); ast_manager_unregister("PJSIPShowResourceLists"); + ast_sip_unregister_service(&pubsub_module); if (sched) { ast_sched_context_destroy(sched); } diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 865483a0938d5bbe037bdad4f87a20831e2f3055..4854c51d03a0f8e51935e54ad93904e07e1a8290 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -2641,14 +2641,18 @@ static int load_module(void) } ast_sip_register_service(&session_reinvite_module); - ast_module_ref(ast_module_info->self); + ast_module_shutdown_ref(ast_module_info->self); return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) { - /* This will never get called as this module can't be unloaded */ + ast_sip_unregister_service(&session_reinvite_module); + ast_sip_unregister_service(&session_module); + ast_sorcery_delete(ast_sip_get_sorcery(), nat_hook); + ao2_cleanup(nat_hook); + ao2_cleanup(sdp_handlers); return 0; }