mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-18 18:46:16 +00:00
Fix a variety of ref counting issues
This patch resolves a number of ref leaks that occur primarily on Asterisk shutdown. It adds a variety of shutdown routines to core portions of Asterisk such that they can reclaim resources allocate duringd initialization. Review: https://reviewboard.asterisk.org/r/2137 ........ Merged revisions 374177 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 374178 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 374196 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374197 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1302,6 +1302,30 @@ int ast_msg_tech_unregister(const struct ast_msg_tech *tech)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ast_msg_shutdown()
|
||||
{
|
||||
if (msg_q_tp) {
|
||||
msg_q_tp = ast_taskprocessor_unreference(msg_q_tp);
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal \brief Clean up other resources on Asterisk shutdown
|
||||
* \note This does not include the msg_q_tp object, which must be disposed
|
||||
* of prior to Asterisk checking for channel destruction in its shutdown
|
||||
* sequence. The atexit handlers are executed after this occurs. */
|
||||
static void message_shutdown(void)
|
||||
{
|
||||
ast_custom_function_unregister(&msg_function);
|
||||
ast_custom_function_unregister(&msg_data_function);
|
||||
ast_unregister_application(app_msg_send);
|
||||
ast_manager_unregister("MessageSend");
|
||||
|
||||
if (msg_techs) {
|
||||
ao2_ref(msg_techs, -1);
|
||||
msg_techs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \internal
|
||||
* \brief Initialize stuff during Asterisk startup.
|
||||
@@ -1331,10 +1355,7 @@ int ast_msg_init(void)
|
||||
res |= ast_register_application2(app_msg_send, msg_send_exec, NULL, NULL, NULL);
|
||||
res |= ast_manager_register_xml_core("MessageSend", EVENT_FLAG_MESSAGE, action_messagesend);
|
||||
|
||||
ast_register_atexit(message_shutdown);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void ast_msg_shutdown(void)
|
||||
{
|
||||
msg_q_tp = ast_taskprocessor_unreference(msg_q_tp);
|
||||
}
|
||||
|
Reference in New Issue
Block a user