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:
Matthew Jordan
2012-10-02 01:47:16 +00:00
parent 4e228fce03
commit a094707d51
24 changed files with 366 additions and 24 deletions

View File

@@ -7023,7 +7023,6 @@ static int load_config(int reload)
return -1;
}
ast_debug(1, "Configuration of default default parking lot done.\n");
parkinglot_addref(default_parkinglot);
}
cfg = ast_config_load2("features.conf", "features", config_flags);
@@ -8958,6 +8957,24 @@ static struct ast_custom_function featuremap_function = {
.write = featuremap_write
};
/*! \internal \brief Clean up resources on Asterisk shutdown */
static void features_shutdown(void)
{
ast_devstate_prov_del("Park");
ast_custom_function_unregister(&featuremap_function);
ast_custom_function_unregister(&feature_function);
ast_manager_unregister("Bridge");
ast_manager_unregister("Park");
ast_manager_unregister("Parkinglots");
ast_manager_unregister("ParkedCalls");
ast_unregister_application(parkcall);
ast_unregister_application(parkedcall);
ast_unregister_application(app_bridge);
pthread_cancel(parking_thread);
ao2_ref(parkinglots, -1);
}
int ast_features_init(void)
{
int res;
@@ -8993,6 +9010,8 @@ int ast_features_init(void)
res |= AST_TEST_REGISTER(features_test);
#endif /* defined(TEST_FRAMEWORK) */
ast_register_atexit(features_shutdown);
return res;
}