summaryrefslogtreecommitdiff
path: root/main/sorcery.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-06-24 23:56:54 +0000
committerMatthew Jordan <mjordan@digium.com>2013-06-24 23:56:54 +0000
commit91217ac3c1fd73efe13407a013260ac7cf937b7b (patch)
tree767bdbef7b458a98b58a15d3953023c0e570b424 /main/sorcery.c
parentf33d074d1a57c4fab55197ec31404b785f90107c (diff)
Fix a variety of memory leaks
This patch addresses the following memory/ref counting leaks: * main/devicestate.c - unsubscribe and join our devicestate message subscription * main/cel.c - clean up the datastore and config objects on exist * main/parking.c - cleanup memory leak of retriever snapshot on message payload destruction * res/parking/parking_bridge.c - cleanup memory leak of retrieve snapshot on message payload destruction * main/presencestate.c - unsubscribe and join the caching topic on exit * manager.c - properly unregister the manager action "BlindTransfer" * sorcery.c - shutdown the threadpool on exit and dispose of any wizards (issue ASTERISK-21906) Reported by: John Hardin patches: cel.patch uploaded by jhardin (license #6512) devicestate.patch uploaded by jhardin (license #6512) manager.patch uploaded by jardin (license #6512) presencestate.patch uploaded by jhardin (license #6512) retriever-channel-snapshot.patch uploaded by jhardin (license #6512) sorcery.patch uploaded by jhardin (license #6512) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392797 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/sorcery.c')
-rw-r--r--main/sorcery.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/main/sorcery.c b/main/sorcery.c
index cf4cd0213..4c60d1da1 100644
--- a/main/sorcery.c
+++ b/main/sorcery.c
@@ -253,6 +253,19 @@ static int sorcery_wizard_cmp(void *obj, void *arg, int flags)
return !strcmp(wizard1->name, flags & OBJ_KEY ? name : wizard2->name) ? CMP_MATCH | CMP_STOP : 0;
}
+/*! \brief Cleanup function */
+static void sorcery_exit(void)
+{
+ ast_threadpool_shutdown(threadpool);
+ threadpool = NULL;
+}
+
+/*! \brief Cleanup function for graceful shutdowns */
+static void sorcery_cleanup(void)
+{
+ ao2_cleanup(wizards);
+}
+
int ast_sorcery_init(void)
{
struct ast_threadpool_options options = {
@@ -265,6 +278,7 @@ int ast_sorcery_init(void)
ast_assert(wizards == NULL);
if (!(threadpool = ast_threadpool_create("Sorcery", NULL, &options))) {
+ threadpool = NULL;
return -1;
}
@@ -273,6 +287,9 @@ int ast_sorcery_init(void)
return -1;
}
+ ast_register_cleanup(sorcery_cleanup);
+ ast_register_atexit(sorcery_exit);
+
return 0;
}