Index: res/res_pjsip_keepalive.c =================================================================== --- res/res_pjsip_keepalive.c (revision 432806) +++ res/res_pjsip_keepalive.c (working copy) @@ -244,7 +244,7 @@ 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; } Index: res/res_pjsip_notify.c =================================================================== --- res/res_pjsip_notify.c (revision 432806) +++ res/res_pjsip_notify.c (working copy) @@ -1021,6 +1021,7 @@ 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; } Index: res/res_pjsip_pubsub.c =================================================================== --- res/res_pjsip_pubsub.c (revision 432806) +++ res/res_pjsip_pubsub.c (working copy) @@ -4286,6 +4286,7 @@ ast_manager_unregister(AMI_SHOW_SUBSCRIPTIONS_INBOUND); ast_manager_unregister("PJSIPShowResourceLists"); + ast_sip_unregister_service(&pubsub_module); if (sched) { ast_sched_context_destroy(sched); } Index: res/res_pjsip_session.c =================================================================== --- res/res_pjsip_session.c (revision 432806) +++ res/res_pjsip_session.c (working copy) @@ -2642,14 +2642,18 @@ } 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; }