[svn-commits] mmichelson: branch group/CCSS r218100 - in /team/group/CCSS: apps/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Sep 11 15:37:40 CDT 2009


Author: mmichelson
Date: Fri Sep 11 15:37:36 2009
New Revision: 218100

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=218100
Log:
Switch to _t_ variants of ao2 functions to help with debugging.

I notice several refcount errors while doin this...


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

Modified: team/group/CCSS/apps/app_dial.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/apps/app_dial.c?view=diff&rev=218100&r1=218099&r2=218100
==============================================================================
--- team/group/CCSS/apps/app_dial.c (original)
+++ team/group/CCSS/apps/app_dial.c Fri Sep 11 15:37:36 2009
@@ -1714,7 +1714,7 @@
 static void dial_cc_interfaces_destroy(void *data)
 {
 	struct dial_cc_interfaces *cc_interfaces = data;
-	ao2_ref(cc_interfaces->interface_tree, -1);
+	ao2_t_ref(cc_interfaces->interface_tree, -1, "Unref dial's ref to interface tree");
 	ast_free(cc_interfaces);
 }
 
@@ -1740,7 +1740,7 @@
 	new_cc_interfaces->done = old_cc_interfaces->done;
 	new_cc_interfaces->dial_parent_id = old_cc_interfaces->dial_parent_id;
 	new_cc_interfaces->core_created = old_cc_interfaces->core_created;
-	ao2_ref(old_cc_interfaces->interface_tree, +1);
+	ao2_t_ref(old_cc_interfaces->interface_tree, +1, "New ref due to duplication of interface tree");
 	new_cc_interfaces->interface_tree = old_cc_interfaces->interface_tree;
 	return new_cc_interfaces;
 }
@@ -1849,7 +1849,8 @@
 		return -1;
 	}
 
-	if (!(interfaces->interface_tree = ao2_alloc(sizeof(*interfaces->interface_tree), ast_cc_interface_tree_destroy))) {
+	if (!(interfaces->interface_tree = ao2_t_alloc(sizeof(*interfaces->interface_tree), ast_cc_interface_tree_destroy,
+					"Allocate interface tree"))) {
 		ast_datastore_free(dial_cc_datastore);
 		ast_free(cc_interface);
 		ast_free(interfaces);

Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=218100&r1=218099&r2=218100
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Fri Sep 11 15:37:36 2009
@@ -531,7 +531,7 @@
 
 static void kill_duplicate_offers(char *caller) {
 	unsigned long match_flags = MATCH_NO_MONITOR;
-	ao2_callback_data(cc_core_instances, OBJ_UNLINK | OBJ_NODATA, match_agent, caller, &match_flags);
+	ao2_t_callback_data(cc_core_instances, OBJ_UNLINK | OBJ_NODATA, match_agent, caller, &match_flags, "Killing duplicate offers");
 }
 
 static void check_callback_sanity(const struct ast_cc_agent_callbacks *callbacks)
@@ -609,7 +609,7 @@
 		ast_free(agent);
 		return NULL;
 	}
-	ao2_ref(interface_tree, +1);
+	ao2_t_ref(interface_tree, +1, "Agent now has reference to interface tree");
 	agent->interface_tree = interface_tree;
 	ast_log(LOG_NOTICE, "I created an agent with core_id %d and caller %s\n", agent->core_id, agent->interface);
 	return agent;
@@ -653,7 +653,7 @@
 
 	if (ast_get_cc_agent_policy(ast_channel_get_cc_config_params(caller_chan)) == AST_CC_AGENT_GENERIC) {
 		unsigned long match_flags = MATCH_MONITOR;
-		if (ao2_callback_data(cc_core_instances, OBJ_NODATA, match_agent, caller, &match_flags) != NULL) {
+		if (ao2_t_callback_data(cc_core_instances, OBJ_NODATA, match_agent, caller, &match_flags, "Trying to find requests from this caller") != NULL) {
 			ast_log(LOG_NOTICE, "Caller %s already has an outstanding CC request. "
 					"Not creating a new core instance\n", caller);
 			return -1;
@@ -661,18 +661,18 @@
 	}
 
 	/* Next, we need to create the core instance for this call */
-	if (!(core_instance = ao2_alloc(sizeof(*core_instance), cc_core_instance_destructor))) {
+	if (!(core_instance = ao2_t_alloc(sizeof(*core_instance), cc_core_instance_destructor, "Creating core instance for CC"))) {
 		return -1;
 	}
 
 	core_instance->core_id = ast_atomic_fetchadd_int(&core_id_counter, +1);
 	if (!(core_instance->agent = cc_agent_init(caller_chan, caller, core_instance->core_id, called_tree))) {
-		ao2_ref(core_instance, -1);
-		return -1;
-	}
-
-	ao2_link(cc_core_instances, core_instance);
-	ao2_ref(core_instance, -1); /* From ao2_alloc. */
+		ao2_t_ref(core_instance, -1, "Couldn't allocate agent, unref core_instance");
+		return -1;
+	}
+
+	ao2_t_link(cc_core_instances, core_instance, "Link core instance into container");
+	ao2_t_ref(core_instance, -1, "Linked core instance, unref from ao2_alloc()"); /* From ao2_alloc. */
 
 	return core_instance->core_id;
 }
@@ -832,7 +832,7 @@
 
 	ast_sched_thread_del(cc_sched_thread, agent_pvt->offer_timer_id);
 
-	ao2_ref(agent->interface_tree, -1);
+	ao2_t_ref(agent->interface_tree, -1, "Agent destructor");
 
 	ast_free(agent_pvt);
 }
@@ -862,7 +862,7 @@
 
 	ast_assert(callbacks != NULL);
 
-	if (!(monitor = ao2_alloc(sizeof(*monitor) + strlen(monitor_name), callbacks->destructor))) {
+	if (!(monitor = ao2_t_alloc(sizeof(*monitor) + strlen(monitor_name), callbacks->destructor, "Allocating new monitor structure"))) {
 		return NULL;
 	}
 
@@ -874,7 +874,7 @@
 	AST_LIST_HEAD_INIT(&monitor->child_links);
 	AST_LIST_HEAD_INIT(&monitor->parent_links);
 	ast_log(LOG_NOTICE, "Created new monitor named %s of type %s\n", monitor->name, monitor->monitor_type);
-	ao2_link(cc_monitors, monitor);
+	ao2_t_link(cc_monitors, monitor, "Link monitor into container");
 	return monitor;
 }
 
@@ -887,7 +887,7 @@
 	strcpy(finder->name, interface->name);
 	finder->monitor_type = interface->monitor_type;
 
-	if ((new_monitor = ao2_find(cc_monitors, finder, OBJ_POINTER))) {
+	if ((new_monitor = ao2_t_find(cc_monitors, finder, OBJ_POINTER, "Trying to find a specific monitor"))) {
 		ast_log(LOG_NOTICE, "Found monitor %s in tree. Re-using\n", new_monitor->name);
 	} else if (!(new_monitor = cc_monitor_instance_init(interface->monitor_class, 
 					interface->monitor_type, interface->name, core_id))) {
@@ -895,8 +895,8 @@
 	}
 
 	if (!(new_link = ast_calloc(1, sizeof(*new_link)))) {
-		ao2_ref(new_monitor, -1);
-		ao2_unlink(cc_monitors, new_monitor);
+		ao2_t_ref(new_monitor, -1, "Couldn't allocate link, so unref monitor");
+		ao2_t_unlink(cc_monitors, new_monitor, "Couldn't allocate link, so unlink monitor");
 		return NULL;
 	}
 
@@ -904,8 +904,8 @@
 	AST_LIST_HEAD_INIT(&new_monitor->child_links);
 	new_link->child = new_monitor;
 	new_link->parent = parent;
-	ao2_ref(new_link->child, +1);
-	ao2_ref(new_link->parent, +1);
+	ao2_t_ref(new_link->child, +1, "Link's child reference");
+	ao2_t_ref(new_link->parent, +1, "Link's parent reference");
 	new_link->core_id = core_id;
 	new_link->service = interface->service_offered;
 	AST_LIST_INSERT_TAIL(&parent->child_links, new_link, next_child);
@@ -927,7 +927,7 @@
 	/* Device monitors won't have children, so don't bother looking.
 	 */
 	if (current_place->monitor_class == AST_CC_DEVICE_MONITOR) {
-		ao2_ref(monitor, -1);
+		ao2_t_ref(monitor, -1, "Device monitor unref from finding or creating");
 		return;
 	}
 
@@ -936,7 +936,7 @@
 			interface_tree_to_monitor(cc_interface, monitor, core_id);
 		}
 	}
-	ao2_ref(monitor, -1);
+	ao2_t_ref(monitor, -1, "Unref extension monitor from finding or creating");
 }
 
 static int cc_monitor_tree_init(const int core_id)
@@ -944,7 +944,7 @@
 	struct cc_core_instance *core_instance;
 	struct cc_core_instance instance_finder = { .core_id = core_id };
 
-	if (!(core_instance = ao2_find(cc_core_instances, &instance_finder, OBJ_POINTER))) {
+	if (!(core_instance = ao2_t_find(cc_core_instances, &instance_finder, OBJ_POINTER, "Find the core instance"))) {
 		return -1;
 	}
 
@@ -954,7 +954,7 @@
 			root_monitor, core_instance->core_id);
 	core_instance->monitor = root_monitor;
 
-	ao2_ref(core_instance, -1);
+	ao2_t_ref(core_instance, -1, "Unref the core instance we just found");
 	return 0;
 }
 
@@ -968,8 +968,8 @@
 {
 	ast_log(LOG_NOTICE, "Destroying link with parent %s and child %s\n",
 			link->parent->name, link->child->name);
-	ao2_ref(link->child, -1);
-	ao2_ref(link->parent, -1);
+	ao2_t_ref(link->child, -1, "Unref link's child");
+	ao2_t_ref(link->parent, -1, "Unref link's parent");
 	ast_free(link);
 	return;
 }
@@ -1000,7 +1000,7 @@
 		/* This should cause the monitor's destructor
 		 * callback to be called
 		 */
-		ao2_unlink(cc_monitors, monitor);
+		ao2_t_unlink(cc_monitors, monitor, "Unlink monitor since nothing refers to it anymore");
 	}
 }
 
@@ -1034,7 +1034,7 @@
 	ast_assert(monitor->monitor_class == AST_CC_EXTENSION_MONITOR ||
 			monitor->monitor_class == AST_CC_ROOT_MONITOR);
 
-	if (!(core_instance = ao2_find(cc_core_instances, &finder, OBJ_POINTER))) {
+	if (!(core_instance = ao2_t_find(cc_core_instances, &finder, OBJ_POINTER, "Find core instance for passing up availability"))) {
 		return -1;
 	}
 
@@ -1135,7 +1135,7 @@
 
 	ast_log(LOG_NOTICE, "State change to %d requested. Reason: %s\n", args->state, args->debug);
 
-	if (!(core_instance = ao2_find(cc_core_instances, &finder, OBJ_POINTER))) {
+	if (!(core_instance = ao2_t_find(cc_core_instances, &finder, OBJ_POINTER, "Find core instance so state change can occur"))) {
 		ast_log(LOG_NOTICE, "Unable to find core instance %d\n", args->core_id);
 		return -1;
 	}
@@ -1244,7 +1244,7 @@
 	}
 
 	ast_free(args);
-	ao2_ref(core_instance, -1); /* From ao2_find */
+	ao2_t_ref(core_instance, -1, "Unref since state change has completed"); /* From ao2_find */
 	return 0;
 }
 
@@ -1282,7 +1282,7 @@
 	}
 
 	match_flags = MATCH_NO_MONITOR;
-	if (!(core_instance = ao2_callback_data(cc_core_instances, 0, match_agent, interface, &match_flags))) {
+	if (!(core_instance = ao2_t_callback_data(cc_core_instances, 0, match_agent, interface, &match_flags, "Find core instance for CallCompletionRequest"))) {
 		ast_log(LOG_NOTICE, "Couldn't find a core instance for caller %s\n", interface);
 		return -1;
 	}
@@ -1313,18 +1313,18 @@
 	}
 
 	match_flags = MATCH_MONITOR;
-	if (!(core_instance = ao2_callback_data(cc_core_instances, 0, match_agent, interface, &match_flags))) {
+	if (!(core_instance = ao2_t_callback_data(cc_core_instances, 0, match_agent, interface, &match_flags, "Find core instance for CallCompletionCancel"))) {
 		ast_log(LOG_WARNING, "Cannot fid CC transaction to cancel for caller %s\n", interface);
 		return -1;
 	}
 
 	if (strcmp(core_instance->agent->callbacks->type, "generic")) {
 		ast_log(LOG_WARNING, "CallCompletionCancel may only be used for calles with a generic agent\n");
-		ao2_ref(core_instance, -1);
+		ao2_t_ref(core_instance, -1, "Unref core instance found during CallCompletionCancel");
 		return -1;
 	}
 	ast_cc_request_state_change(CC_FAILED, core_instance->core_id, "Call completion request Cancelled");
-	ao2_ref(core_instance, -1);
+	ao2_t_ref(core_instance, -1, "Unref core instance found during CallCompletionCancel");
 	return 0;
 }
 
@@ -1606,14 +1606,14 @@
 {
 	struct ast_cc_interface_tree *interface_tree = data;
 	struct ast_cc_interface_tree *output = interface_tree;
-	ao2_ref(output, +1);
+	ao2_t_ref(output, +1, "Bump refcount of interface tree for recall");
 	return NULL;
 }
 
 static void cc_recall_ds_destroy(void *data)
 {
 	struct ast_cc_interface_tree *interface_tree = data;
-	ao2_ref(interface_tree, -1);
+	ao2_t_ref(interface_tree, -1, "Unref recall interface tree");
 }
 
 static struct ast_datastore_info recall_ds_info = {
@@ -1629,7 +1629,7 @@
 	if (!recall_datastore) {
 		return -1;
 	}
-	ao2_ref(agent->interface_tree, +1);
+	ao2_t_ref(agent->interface_tree, +1, "Bump refcount for interface tree for agent");
 	recall_datastore->data = agent->interface_tree;
 	recall_datastore->inheritance = DATASTORE_INHERIT_FOREVER;
 	ast_channel_lock(chan);
@@ -1690,13 +1690,15 @@
 	int res;
 
 	ast_log(LOG_NOTICE, "Successfully created pending offers container\n");
-	if (!(cc_core_instances = ao2_container_alloc(CC_CORE_INSTANCES_BUCKETS,
-					cc_core_instance_hash_fn, cc_core_instance_cmp_fn))) {
+	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;
 	}
 	ast_log(LOG_NOTICE, "Successfully created core instancess container\n");
-	if (!(cc_monitors = ao2_container_alloc(CC_CORE_INSTANCES_BUCKETS,
-					cc_monitor_hash_fn, cc_monitor_cmp_fn))) {
+	if (!(cc_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
+					cc_monitor_hash_fn, cc_monitor_cmp_fn,
+					"Create monitor container"))) {
 		return -1;
 	}
 	ast_log(LOG_NOTICE, "Successfully created monitors  container\n");
@@ -1721,6 +1723,6 @@
 		return -1;
 	}
 	ast_log(LOG_NOTICE, "Successfully created the root CC monitor\n");
-	ao2_ref(root_monitor, -1);
+	ao2_t_ref(root_monitor, -1, "Unref root monitor from allocation");
 	return res;
 }




More information about the svn-commits mailing list