[asterisk-commits] mmichelson: branch group/CCSS r220224 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 24 14:14:44 CDT 2009


Author: mmichelson
Date: Thu Sep 24 14:14:41 2009
New Revision: 220224

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=220224
Log:
Clean up more destructor code.

On to the monitors next!


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=220224&r1=220223&r2=220224
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Sep 24 14:14:41 2009
@@ -139,6 +139,8 @@
 	 */
 };
 
+static void prune_links(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *link_parent);
+
 static int print_debug(void *obj, void *args, int flags)
 {
 	struct ast_cc_monitor *monitor = obj;
@@ -634,10 +636,20 @@
 	return agent;
 }
 
+static void agent_destroy(struct ast_cc_agent *agent) {
+	agent->interface_tree = cc_unref(agent->interface_tree, "Destroying agent, removing ref to interface tree");
+	agent->callbacks->destructor(agent);
+	ast_free(agent);
+}
+
 static void cc_core_instance_destructor(void *data)
 {
 	struct cc_core_instance *core_instance = data;
-	ast_free(core_instance->agent);
+	ast_log(LOG_NOTICE, "Destroying core instance %d\n", core_instance->core_id);
+	agent_destroy(core_instance->agent);
+	if (core_instance->monitor) {
+		prune_links(core_instance->monitor, core_instance->core_id, NULL);
+	}
 }
 
 static int cc_core_instance_hash_fn(const void *obj, const int flags)
@@ -859,12 +871,6 @@
 	}
 
 	ast_free(agent_pvt);
-}
-
-static void agent_destroy(struct ast_cc_agent *agent) {
-	agent->interface_tree = cc_unref(agent->interface_tree, "Destroying agent, removing ref to interface tree");
-	agent->callbacks->destructor(agent);
-	ast_free(agent);
 }
 
 static const struct ast_cc_monitor_callbacks *find_monitor_callbacks(const char * const type)
@@ -1270,16 +1276,12 @@
 			ast_log(LOG_NOTICE, "Invalid state change request. Cannot go from %d to %d\n", core_instance->current_state, args->state);
 		}
 		core_instance->current_state = args->state;
-		agent_destroy(core_instance->agent);
-		prune_links(core_instance->monitor, core_instance->core_id, NULL);
+		ao2_t_unlink(cc_core_instances, core_instance, "Unlink core instance since CC recall has completed");
 		break;
 	case CC_FAILED:
 		/* Something along the way failed, call agent and monitor destructor functions
 		 */
-		agent_destroy(core_instance->agent);
-		if (core_instance->monitor) {
-			prune_links(core_instance->monitor, core_instance->core_id, NULL);
-		}
+		ao2_t_unlink(cc_core_instances, core_instance, "Unlink core instance since CC failed");
 		break;
 	default:
 		ast_log(LOG_WARNING, "Asked to change to non-existent state %d. Ignoring\n", args->state);




More information about the asterisk-commits mailing list