[asterisk-commits] mmichelson: branch group/CCSS_Monitor_Restructure r242091 - /team/group/CCSS_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 21 16:29:05 CST 2010


Author: mmichelson
Date: Thu Jan 21 16:29:02 2010
New Revision: 242091

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=242091
Log:
Remove more unused code.


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

Modified: team/group/CCSS_Monitor_Restructure/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/main/ccss.c?view=diff&rev=242091&r1=242090&r2=242091
==============================================================================
--- team/group/CCSS_Monitor_Restructure/main/ccss.c (original)
+++ team/group/CCSS_Monitor_Restructure/main/ccss.c Thu Jan 21 16:29:02 2010
@@ -69,7 +69,6 @@
 static struct ast_sched_thread *cc_sched_thread;
 static const int CC_CORE_INSTANCES_BUCKETS = 17;
 static int core_id_counter;
-static struct ast_cc_monitor *root_monitor;
 static struct ast_taskprocessor *cc_core_taskprocessor;
 
 #define cc_ref(obj, debug) ({ao2_t_ref((obj), +1, (debug)); (obj);})
@@ -374,26 +373,6 @@
 	return 0;
 }
 
-static struct ao2_container *cc_monitors;
-
-static int cc_monitor_cmp_fn(void *obj, void *arg, int flags)
-{
-	struct ast_cc_monitor *monitor1 = obj;
-	struct ast_cc_monitor *monitor2 = arg;
-
-	if (!strcmp(monitor1->interface->name, monitor2->interface->name) &&
-			!strcmp(monitor1->interface->monitor_type, monitor2->interface->monitor_type)) {
-		return CMP_MATCH | CMP_STOP;
-	}
-	return 0;
-}
-
-static int cc_monitor_hash_fn(const void *obj, int flags)
-{
-	const struct ast_cc_monitor *monitor = obj;
-	return ast_str_hash_add(monitor->interface->monitor_type, ast_str_hash(monitor->interface->name));
-}
-
 static const unsigned int CC_OFFER_TIMER_DEFAULT = 20u;
 static const unsigned int CCNR_AVAILABLE_TIMER_DEFAULT = 7200u;
 static const unsigned int CCBS_AVAILABLE_TIMER_DEFAULT = 4800u;
@@ -820,18 +799,6 @@
 	}
 	AST_RWLIST_UNLOCK(&cc_agent_backends);
 	return callbacks;
-}
-
-static void destroy_link(struct ast_cc_monitor_link *link)
-{
-	ast_log_dynamic_level(cc_logger_level, "Destroying link with parent %s and child %s\n",
-			link->parent->interface->name, link->child->interface->name);
-	ast_atomic_fetchadd_int(&link->child->num_requests, -1);
-	link->child->callbacks->instance_destructor(link->core_id);
-	link->child = cc_unref(link->child, "Unref link's child");
-	link->parent = cc_unref(link->parent, "Unref link's parent");
-	ast_free(link);
-	return;
 }
 
 /*!
@@ -2268,45 +2235,6 @@
 	ao2_t_link(cc_core_instances, core_instance, "Link core instance into container");
 
 	return core_instance;
-}
-
-static void monitor_destroy(void *data)
-{
-	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");
-}
-
-static struct ast_cc_monitor *cc_monitor_instance_init(struct ast_cc_interface *cc_interface,
-		const int core_id)
-{
-	struct ast_cc_monitor *monitor;
-	const struct ast_cc_monitor_callbacks *callbacks = find_monitor_callbacks(cc_interface->monitor_type);
-
-	ast_assert(callbacks != NULL);
-
-	if (!(monitor = ao2_t_alloc(sizeof(*monitor), monitor_destroy, "Allocating new monitor structure"))) {
-		return NULL;
-	}
-
-	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_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
-	ao2_callback(cc_monitors, OBJ_NODATA, print_debug, NULL);
-#endif
-	return monitor;
 }
 
 struct cc_state_change_args {
@@ -3398,16 +3326,6 @@
 	return data.count;
 }
 
-static struct ast_cc_interface *root_interface_init(void)
-{
-	struct ast_cc_interface *cc_interface = ao2_alloc(sizeof(*cc_interface) + strlen("root"), cc_interface_destroy);
-
-	strcpy(cc_interface->name, "root");
-	cc_interface->monitor_class = AST_CC_ROOT_MONITOR;
-	cc_interface->monitor_type = "extension";
-	return cc_interface;
-}
-
 static void initialize_cc_max_requests(void)
 {
 	struct ast_config *cc_config;
@@ -3527,20 +3445,10 @@
 int ast_cc_init(void)
 {
 	int res;
-	struct ast_cc_interface *root_interface = root_interface_init();
-
-	if (!root_interface) {
-		return -1;
-	}
 
 	if (!(cc_core_instances = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
 					cc_core_instance_hash_fn, cc_core_instance_cmp_fn,
 					"Create core instance container"))) {
-		return -1;
-	}
-	if (!(cc_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
-					cc_monitor_hash_fn, cc_monitor_cmp_fn,
-					"Create monitor container"))) {
 		return -1;
 	}
 	if (!(generic_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
@@ -3559,17 +3467,8 @@
 	res |= ast_cc_monitor_register(&extension_monitor_cbs);
 	res |= ast_cc_monitor_register(&generic_monitor_cbs);
 	res |= ast_cc_agent_register(&generic_agent_callbacks);
-	/* Root monitor doesn't care about the core id. The root monitor uses
-	 * extension monitor callbacks since the gist of those will be to traverse
-	 * their child links and call each of their children's callbacks
-	 */
-	if (!(root_monitor = cc_monitor_instance_init(root_interface, -1))) {
-		return -1;
-	}
 	ast_cli_register_multiple(cc_cli, ARRAY_LEN(cc_cli));
 	cc_logger_level = ast_logger_register_level(CC_LOGGER_LEVEL_NAME);
-	/* FOR THE LOVE OF GOD DO NOT SET root_monitor TO NULL HERE */
-	cc_unref(root_monitor, "Unref root monitor from allocation");
 	dialed_cc_interface_counter = 1;
 	initialize_cc_max_requests();
 	return res;




More information about the asterisk-commits mailing list