mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 12:52:33 +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:
27
main/ccss.c
27
main/ccss.c
@@ -4520,6 +4520,31 @@ static struct ast_cli_entry cc_cli[] = {
|
||||
AST_CLI_DEFINE(handle_cc_kill, "Kill a CC transaction"),
|
||||
};
|
||||
|
||||
static void cc_shutdown(void)
|
||||
{
|
||||
ast_devstate_prov_del("ccss");
|
||||
ast_cc_agent_unregister(&generic_agent_callbacks);
|
||||
ast_cc_monitor_unregister(&generic_monitor_cbs);
|
||||
ast_unregister_application(cccancel_app);
|
||||
ast_unregister_application(ccreq_app);
|
||||
|
||||
if (cc_sched_context) {
|
||||
ast_sched_context_destroy(cc_sched_context);
|
||||
cc_sched_context = NULL;
|
||||
}
|
||||
if (cc_core_taskprocessor) {
|
||||
cc_core_taskprocessor = ast_taskprocessor_unreference(cc_core_taskprocessor);
|
||||
}
|
||||
if (generic_monitors) {
|
||||
ao2_t_ref(generic_monitors, -1, "Unref generic_monitor container in cc_shutdown");
|
||||
generic_monitors = NULL;
|
||||
}
|
||||
if (cc_core_instances) {
|
||||
ao2_t_ref(cc_core_instances, -1, "Unref cc_core_instances container in cc_shutdown");
|
||||
cc_core_instances = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int ast_cc_init(void)
|
||||
{
|
||||
int res;
|
||||
@@ -4557,5 +4582,7 @@ int ast_cc_init(void)
|
||||
initialize_cc_devstate_map();
|
||||
res |= ast_devstate_prov_add("ccss", ccss_device_state);
|
||||
|
||||
ast_register_atexit(cc_shutdown);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user