[asterisk-commits] mjordan: trunk r392797 - in /trunk: main/ res/parking/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 24 18:56:56 CDT 2013


Author: mjordan
Date: Mon Jun 24 18:56:54 2013
New Revision: 392797

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392797
Log:
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)


Modified:
    trunk/main/cdr.c
    trunk/main/cel.c
    trunk/main/devicestate.c
    trunk/main/manager.c
    trunk/main/parking.c
    trunk/main/presencestate.c
    trunk/main/sorcery.c
    trunk/res/parking/parking_bridge.c

Modified: trunk/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cdr.c?view=diff&rev=392797&r1=392796&r2=392797
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Mon Jun 24 18:56:54 2013
@@ -3514,7 +3514,6 @@
 	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 @@
 	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);
 }

Modified: trunk/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cel.c?view=diff&rev=392797&r1=392796&r2=392797
==============================================================================
--- trunk/main/cel.c (original)
+++ trunk/main/cel.c Mon Jun 24 18:56:54 2013
@@ -1415,6 +1415,8 @@
 
 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 @@
 	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(bridge_primaries);
+	bridge_primaries = NULL;
+	ast_cli_unregister(&cli_status);
+	ao2_cleanup(cel_dialstatus_store);
+	cel_dialstatus_store = NULL;
 	ao2_cleanup(linkedids);
 	linkedids = NULL;
-	ast_cli_unregister(&cli_status);
-	ao2_cleanup(bridge_primaries);
-	bridge_primaries = NULL;
 }
 
 int ast_cel_engine_init(void)

Modified: trunk/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/devicestate.c?view=diff&rev=392797&r1=392796&r2=392797
==============================================================================
--- trunk/main/devicestate.c (original)
+++ trunk/main/devicestate.c Mon Jun 24 18:56:54 2013
@@ -774,6 +774,7 @@
 
 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);

Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=392797&r1=392796&r2=392797
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Mon Jun 24 18:56:54 2013
@@ -7659,6 +7659,7 @@
 		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));
 	}

Modified: trunk/main/parking.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/parking.c?view=diff&rev=392797&r1=392796&r2=392797
==============================================================================
--- trunk/main/parking.c (original)
+++ trunk/main/parking.c Mon Jun 24 18:56:54 2013
@@ -80,6 +80,7 @@
 
 	ao2_cleanup(park_obj->parkee);
 	ao2_cleanup(park_obj->parker);
+	ao2_cleanup(park_obj->retriever);
 	ast_string_field_free_memory(park_obj);
 }
 

Modified: trunk/main/presencestate.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/presencestate.c?view=diff&rev=392797&r1=392796&r2=392797
==============================================================================
--- trunk/main/presencestate.c (original)
+++ trunk/main/presencestate.c Mon Jun 24 18:56:54 2013
@@ -314,8 +314,7 @@
 {
 	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);
 }
 

Modified: trunk/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/sorcery.c?view=diff&rev=392797&r1=392796&r2=392797
==============================================================================
--- trunk/main/sorcery.c (original)
+++ trunk/main/sorcery.c Mon Jun 24 18:56:54 2013
@@ -253,6 +253,19 @@
 	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 @@
 	ast_assert(wizards == NULL);
 
 	if (!(threadpool = ast_threadpool_create("Sorcery", NULL, &options))) {
+		threadpool = NULL;
 		return -1;
 	}
 
@@ -272,6 +286,9 @@
 		ast_threadpool_shutdown(threadpool);
 		return -1;
 	}
+
+	ast_register_cleanup(sorcery_cleanup);
+	ast_register_atexit(sorcery_exit);
 
 	return 0;
 }

Modified: trunk/res/parking/parking_bridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/parking/parking_bridge.c?view=diff&rev=392797&r1=392796&r2=392797
==============================================================================
--- trunk/res/parking/parking_bridge.c (original)
+++ trunk/res/parking/parking_bridge.c Mon Jun 24 18:56:54 2013
@@ -66,10 +66,8 @@
 	struct parked_user *pu = obj;
 
 	ao2_cleanup(pu->lot);
-	pu->lot = NULL;
-
 	ao2_cleanup(pu->parker);
-	pu->parker = NULL;
+	ao2_cleanup(pu->retriever);
 }
 
 /*!




More information about the asterisk-commits mailing list