diff options
author | Matthew Jordan <mjordan@digium.com> | 2012-10-02 01:47:16 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2012-10-02 01:47:16 +0000 |
commit | a094707d5156a005fb6e9277bd4a14f9d7e7ab1c (patch) | |
tree | 26a15c7ef864995e2f2d89d09294024bad0145cb /main/features.c | |
parent | 4e228fce0382550136e5c34cb4d9fd400b8d4ad3 (diff) |
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
Diffstat (limited to 'main/features.c')
-rw-r--r-- | main/features.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/main/features.c b/main/features.c index f89ca816d..e84a2a271 100644 --- a/main/features.c +++ b/main/features.c @@ -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; } |