summaryrefslogtreecommitdiff
path: root/main
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
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')
-rw-r--r--main/cdr.c7
-rw-r--r--main/cel.c10
-rw-r--r--main/devicestate.c1
-rw-r--r--main/manager.c1
-rw-r--r--main/parking.c1
-rw-r--r--main/presencestate.c3
-rw-r--r--main/sorcery.c17
7 files changed, 34 insertions, 6 deletions
diff --git a/main/cdr.c b/main/cdr.c
index 2ec684837..64a2bb490 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -3514,7 +3514,6 @@ static void cdr_engine_shutdown(void)
ao2_callback(active_cdrs_by_channel, OBJ_NODATA, cdr_object_dispatch_all_cb,
NULL);
finalize_batch_mode();
- aco_info_destroy(&cfg_info);
ast_cli_unregister(&cli_status);
ast_cli_unregister(&cli_debug);
ast_sched_context_destroy(sched);
@@ -3522,6 +3521,12 @@ static void cdr_engine_shutdown(void)
ast_free(batch);
batch = NULL;
+ channel_subscription = stasis_unsubscribe_and_join(channel_subscription);
+ bridge_subscription = stasis_unsubscribe_and_join(bridge_subscription);
+ stasis_message_router_unsubscribe_and_join(stasis_router);
+ aco_info_destroy(&cfg_info);
+ ao2_global_obj_release(module_configs);
+
ao2_ref(active_cdrs_by_channel, -1);
ao2_ref(active_cdrs_by_bridge, -1);
}
diff --git a/main/cel.c b/main/cel.c
index b3802c7ee..7185acf59 100644
--- a/main/cel.c
+++ b/main/cel.c
@@ -1415,6 +1415,8 @@ static void cel_dial_cb(void *data, struct stasis_subscription *sub,
static void ast_cel_engine_term(void)
{
+ aco_info_destroy(&cel_cfg_info);
+ ao2_global_obj_release(cel_configs);
stasis_message_router_unsubscribe_and_join(cel_state_router);
cel_state_router = NULL;
ao2_cleanup(cel_state_topic);
@@ -1422,11 +1424,13 @@ static void ast_cel_engine_term(void)
cel_channel_forwarder = stasis_unsubscribe_and_join(cel_channel_forwarder);
cel_bridge_forwarder = stasis_unsubscribe_and_join(cel_bridge_forwarder);
cel_parking_forwarder = stasis_unsubscribe_and_join(cel_parking_forwarder);
- ao2_cleanup(linkedids);
- linkedids = NULL;
- ast_cli_unregister(&cli_status);
ao2_cleanup(bridge_primaries);
bridge_primaries = NULL;
+ ast_cli_unregister(&cli_status);
+ ao2_cleanup(cel_dialstatus_store);
+ cel_dialstatus_store = NULL;
+ ao2_cleanup(linkedids);
+ linkedids = NULL;
}
int ast_cel_engine_init(void)
diff --git a/main/devicestate.c b/main/devicestate.c
index 2f753bdd7..b2c70f764 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -774,6 +774,7 @@ static const char *device_state_get_id(struct stasis_message *message)
static void devstate_cleanup(void)
{
+ devstate_message_sub = stasis_unsubscribe_and_join(devstate_message_sub);
ao2_cleanup(device_state_topic_all);
device_state_topic_all = NULL;
device_state_topic_cached = stasis_caching_unsubscribe_and_join(device_state_topic_cached);
diff --git a/main/manager.c b/main/manager.c
index a1b0c7fea..8f4fffbf2 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -7659,6 +7659,7 @@ static void manager_shutdown(void)
ast_manager_unregister("ModuleCheck");
ast_manager_unregister("AOCMessage");
ast_manager_unregister("Filter");
+ ast_manager_unregister("BlindTransfer");
ast_custom_function_unregister(&managerclient_function);
ast_cli_unregister_multiple(cli_manager, ARRAY_LEN(cli_manager));
}
diff --git a/main/parking.c b/main/parking.c
index fa1c4d88a..a3da860b7 100644
--- a/main/parking.c
+++ b/main/parking.c
@@ -80,6 +80,7 @@ static void parked_call_payload_destructor(void *obj)
ao2_cleanup(park_obj->parkee);
ao2_cleanup(park_obj->parker);
+ ao2_cleanup(park_obj->retriever);
ast_string_field_free_memory(park_obj);
}
diff --git a/main/presencestate.c b/main/presencestate.c
index 2eab99177..45174d5a1 100644
--- a/main/presencestate.c
+++ b/main/presencestate.c
@@ -314,8 +314,7 @@ static void presence_state_engine_cleanup(void)
{
ao2_cleanup(presence_state_topic_all);
presence_state_topic_all = NULL;
- ao2_cleanup(presence_state_topic_cached);
- presence_state_topic_cached = NULL;
+ presence_state_topic_cached = stasis_caching_unsubscribe_and_join(presence_state_topic_cached);
STASIS_MESSAGE_TYPE_CLEANUP(ast_presence_state_message_type);
}
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;
}