[asterisk-commits] rmudgett: branch group/CCSS r240712 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 15 19:30:29 CST 2010


Author: rmudgett
Date: Fri Jan 15 19:30:27 2010
New Revision: 240712

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=240712
Log:
More constructor/destructor fixes.

*  Fix cc_monitor_instance_init() so it can be destroyed if construction
fails.
*  Fix cc_generic_monitor_destructor() in case the parent constructor
failed.
*  Fix cc_interface_tree_destroy() to also destroy the list.

Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=240712&r1=240711&r2=240712
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Fri Jan 15 19:30:27 2010
@@ -1211,7 +1211,7 @@
 	struct generic_monitor_pvt *gen_mon_pvt = monitor->private_data;
 
 	ast_log_dynamic_level(cc_logger_level, "Destroying generic monitor private\n");
-	if (gen_mon_pvt->sub) {
+	if (gen_mon_pvt && gen_mon_pvt->sub) {
 		gen_mon_pvt->sub = ast_event_unsubscribe(gen_mon_pvt->sub);
 	}
 	ast_free(gen_mon_pvt);
@@ -1292,6 +1292,7 @@
 	while ((tree_item = AST_LIST_REMOVE_HEAD(cc_interface_tree, next))) {
 		cc_tree_item_destroy(tree_item);
 	}
+	AST_LIST_HEAD_DESTROY(cc_interface_tree);
 }
 
 /*!
@@ -2292,6 +2293,8 @@
 	struct ast_cc_monitor *monitor = data;
 	ast_log_dynamic_level(cc_logger_level, "Destructor called for monitor %s\n", monitor->interface->name);
 	monitor->callbacks->destructor(monitor);
+	AST_LIST_HEAD_DESTROY(&monitor->child_links);
+	AST_LIST_HEAD_DESTROY(&monitor->parent_links);
 	cc_unref(monitor->interface, "Remove monitor's reference to interface");
 }
 
@@ -2309,13 +2312,13 @@
 
 	monitor->interface = cc_ref(cc_interface, "monitor gains reference to interface");
 	monitor->callbacks = callbacks;
+	AST_LIST_HEAD_INIT(&monitor->child_links);
+	AST_LIST_HEAD_INIT(&monitor->parent_links);
 	if (monitor->callbacks->init(monitor, core_id)) {
 		ast_log_dynamic_level(cc_logger_level, "Init monitor callback failed for monitor %s\n", callbacks->type);
 		cc_unref(monitor, "Monitor init callback failed");
 		return NULL;
 	}
-	AST_LIST_HEAD_INIT(&monitor->child_links);
-	AST_LIST_HEAD_INIT(&monitor->parent_links);
 	ast_log_dynamic_level(cc_logger_level, "Created new monitor named %s of type %s\n", monitor->interface->name, monitor->interface->monitor_type);
 	ao2_t_link(cc_monitors, monitor, "Link monitor into container");
 #if 0




More information about the asterisk-commits mailing list