[asterisk-commits] rmudgett: trunk r374269 - /trunk/main/astobj2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 2 17:39:51 CDT 2012


Author: rmudgett
Date: Tue Oct  2 17:39:47 2012
New Revision: 374269

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=374269
Log:
* Add ref debug tags to astobj2.c ref usage.

* Make container nodes not show up in the ref debug log.

Modified:
    trunk/main/astobj2.c

Modified: trunk/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/astobj2.c?view=diff&rev=374269&r1=374268&r2=374269
==============================================================================
--- trunk/main/astobj2.c (original)
+++ trunk/main/astobj2.c Tue Oct  2 17:39:47 2012
@@ -1203,13 +1203,13 @@
 		 * is destroyed, the container will be automatically
 		 * destroyed as well.
 		 */
-		multi_container = __ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL,
-			NULL);
+		multi_container = ao2_t_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL,
+			NULL, "OBJ_MULTIPLE return container creation");
 		if (!multi_container) {
 			return NULL;
 		}
 		if (!(multi_iterator = ast_calloc(1, sizeof(*multi_iterator)))) {
-			ao2_ref(multi_container, -1);
+			ao2_t_ref(multi_container, -1, "OBJ_MULTIPLE interator creation failed.");
 			return NULL;
 		}
 	}
@@ -1308,7 +1308,7 @@
 						if (tag) {
 							__ao2_ref_debug(ret, 1, tag, file, line, func);
 						} else {
-							__ao2_ref(ret, 1);
+							ao2_t_ref(ret, 1, "Traversal found object");
 						}
 					}
 				}
@@ -1348,17 +1348,13 @@
 					if (tag) {
 						__ao2_ref_debug(node->obj, -1, tag, file, line, func);
 					} else {
-						__ao2_ref(node->obj, -1);
+						ao2_t_ref(node->obj, -1, "Unlink container obj reference.");
 					}
 				}
 				node->obj = NULL;
 
 				/* Unref the node from the container. */
-				if (tag) {
-					__ao2_ref_debug(node, -1, tag, file, line, func);
-				} else {
-					__ao2_ref(node, -1);
-				}
+				__ao2_ref(node, -1);
 			}
 		}
 
@@ -1385,7 +1381,8 @@
 	if (multi_container) {
 		*multi_iterator = ao2_iterator_init(multi_container,
 			AO2_ITERATOR_UNLINK | AO2_ITERATOR_MALLOCD);
-		ao2_ref(multi_container, -1);
+		ao2_t_ref(multi_container, -1,
+			"OBJ_MULTIPLE for multiple objects traversal complete.");
 		return multi_iterator;
 	} else {
 		return ret;
@@ -1456,7 +1453,7 @@
 		.flags = flags
 	};
 
-	ao2_ref(c, +1);
+	ao2_t_ref(c, +1, "Init iterator with container.");
 
 	return a;
 }
@@ -1479,7 +1476,7 @@
 			ao2_rdlock(iter->c);
 		}
 
-		ao2_ref(iter->last_node, -1);
+		__ao2_ref(iter->last_node, -1);
 		iter->last_node = NULL;
 
 		if (iter->flags & AO2_ITERATOR_DONTLOCK) {
@@ -1581,7 +1578,7 @@
 			if (tag) {
 				__ao2_ref_debug(ret, +1, tag, file, line, func);
 			} else {
-				__ao2_ref(ret, +1);
+				ao2_t_ref(ret, +1, "Next iterator object.");
 			}
 
 			/* Bump the container's node ref for the iterator. */
@@ -1686,7 +1683,7 @@
 	obj = __ao2_callback(src, OBJ_NOLOCK, dup_obj_cb, dest);
 	if (obj) {
 		/* Failed to put this obj into the dest container. */
-		__ao2_ref(obj, -1);
+		ao2_t_ref(obj, -1, "Failed to put this object into the dest container.");
 
 		/* Remove all items from the dest container. */
 		__ao2_callback(dest, OBJ_NOLOCK | OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL,
@@ -1726,7 +1723,7 @@
 	}
 	if (failed) {
 		/* Object copy into the clone container failed. */
-		__ao2_ref(clone, -1);
+		ao2_t_ref(clone, -1, "Clone creation failed.");
 		clone = NULL;
 	}
 	return clone;
@@ -1760,7 +1757,7 @@
 		if (ref_debug) {
 			__ao2_ref_debug(clone, -1, tag, file, line, func);
 		} else {
-			__ao2_ref(clone, -1);
+			ao2_t_ref(clone, -1, "Clone creation failed.");
 		}
 		clone = NULL;
 	}
@@ -1901,8 +1898,8 @@
 	}
 	ao2_options = orig_obj->priv_data.options;
 
-	return __ao2_container_alloc_hash(ao2_options, self->common.options, self->n_buckets,
-		self->hash_fn, self->common.sort_fn, self->common.cmp_fn);
+	return ao2_t_container_alloc_hash(ao2_options, self->common.options, self->n_buckets,
+		self->hash_fn, self->common.sort_fn, self->common.cmp_fn, "Clone hash container");
 }
 
 /*!
@@ -1988,7 +1985,7 @@
 	 * destroyed or the node had not been linked in yet.
 	 */
 	if (doomed->common.obj) {
-		ao2_ref(doomed->common.obj, -1);
+		ao2_t_ref(doomed->common.obj, -1, "Container node destruction");
 		doomed->common.obj = NULL;
 	}
 }
@@ -2013,7 +2010,7 @@
 	struct hash_bucket_node *node;
 	int i;
 
-	node = ao2_t_alloc_options(sizeof(*node), hash_ao2_node_destructor, AO2_ALLOC_OPT_LOCK_NOLOCK, "Create hash node");
+	node = __ao2_alloc(sizeof(*node), hash_ao2_node_destructor, AO2_ALLOC_OPT_LOCK_NOLOCK);
 	if (!node) {
 		return NULL;
 	}
@@ -2024,7 +2021,7 @@
 	if (tag) {
 		__ao2_ref_debug(obj_new, +1, tag, file, line, func);
 	} else {
-		__ao2_ref(obj_new, +1);
+		ao2_t_ref(obj_new, +1, "Container node creation");
 	}
 	node->common.obj = obj_new;
 	node->common.my_container = (struct ao2_container *) self;
@@ -3217,7 +3214,7 @@
 	struct ao2_reg_container *doomed = v_doomed;
 
 	if (doomed->registered) {
-		ao2_ref(doomed->registered, -1);
+		ao2_t_ref(doomed->registered, -1, "Releasing registered container.");
 	}
 }
 #endif	/* defined(AST_DEVMODE) */
@@ -3228,22 +3225,22 @@
 #if defined(AST_DEVMODE)
 	struct ao2_reg_container *reg;
 
-	reg = ao2_alloc_options(sizeof(*reg) + strlen(name), ao2_reg_destructor,
-		AO2_ALLOC_OPT_LOCK_NOLOCK);
+	reg = ao2_t_alloc_options(sizeof(*reg) + strlen(name), ao2_reg_destructor,
+		AO2_ALLOC_OPT_LOCK_NOLOCK, "Container registration object.");
 	if (!reg) {
 		return -1;
 	}
 
 	/* Fill in registered entry */
-	ao2_ref(self, +1);
+	ao2_t_ref(self, +1, "Registering container.");
 	reg->registered = self;
 	strcpy(reg->name, name);/* safe */
 
-	if (!ao2_link(reg_containers, reg)) {
+	if (!ao2_t_link(reg_containers, reg, "Save registration object.")) {
 		res = -1;
 	}
 
-	ao2_ref(reg, -1);
+	ao2_t_ref(reg, -1, "Done registering container.");
 #endif	/* defined(AST_DEVMODE) */
 	return res;
 }
@@ -3251,7 +3248,8 @@
 void ao2_container_unregister(const char *name)
 {
 #if defined(AST_DEVMODE)
-	ao2_find(reg_containers, name, OBJ_UNLINK | OBJ_NODATA | OBJ_KEY);
+	ao2_t_find(reg_containers, name, OBJ_UNLINK | OBJ_NODATA | OBJ_KEY,
+		"Unregister container");
 #endif	/* defined(AST_DEVMODE) */
 }
 
@@ -3281,11 +3279,11 @@
 	partial_key.name = a->word;
 	which.find_nth = a->n;
 	which.count = 0;
-	reg = ao2_callback_data(reg_containers, partial_key.len ? OBJ_PARTIAL_KEY : 0,
-		ao2_complete_reg_cb, &partial_key, &which);
+	reg = ao2_t_callback_data(reg_containers, partial_key.len ? OBJ_PARTIAL_KEY : 0,
+		ao2_complete_reg_cb, &partial_key, &which, "Find partial registered container");
 	if (reg) {
 		name = ast_strdup(reg->name);
-		ao2_ref(reg, -1);
+		ao2_t_ref(reg, -1, "Done with registered container object.");
 	} else {
 		name = NULL;
 	}
@@ -3316,10 +3314,10 @@
 	}
 
 	name = a->argv[3];
-	reg = ao2_find(reg_containers, name, OBJ_KEY);
+	reg = ao2_t_find(reg_containers, name, OBJ_KEY, "Find registered container");
 	if (reg) {
 		ao2_container_stats(reg->registered, a->fd, ast_cli);
-		ao2_ref(reg, -1);
+		ao2_t_ref(reg, -1, "Done with registered container object.");
 	} else {
 		ast_cli(a->fd, "Container '%s' not found.\n", name);
 	}
@@ -3351,11 +3349,11 @@
 	}
 
 	name = a->argv[3];
-	reg = ao2_find(reg_containers, name, OBJ_KEY);
+	reg = ao2_t_find(reg_containers, name, OBJ_KEY, "Find registered container");
 	if (reg) {
 		ast_cli(a->fd, "Container check of '%s': %s.\n", name,
 			ao2_container_check(reg->registered, 0) ? "failed" : "OK");
-		ao2_ref(reg, -1);
+		ao2_t_ref(reg, -1, "Done with registered container object.");
 	} else {
 		ast_cli(a->fd, "Container '%s' not found.\n", name);
 	}
@@ -3380,15 +3378,17 @@
 #if defined(AST_DEVMODE)
 static void astobj2_cleanup(void)
 {
-	ao2_ref(reg_containers, -1);
+	ao2_t_ref(reg_containers, -1, "Releasing container registration container");
+	reg_containers = NULL;
 }
 #endif
 
 int astobj2_init(void)
 {
 #if defined(AST_DEVMODE)
-	reg_containers = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_RWLOCK,
-		AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ao2_reg_sort_cb, NULL);
+	reg_containers = ao2_t_container_alloc_list(AO2_ALLOC_OPT_LOCK_RWLOCK,
+		AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ao2_reg_sort_cb, NULL,
+		"Container registration container.");
 	if (!reg_containers) {
 		return -1;
 	}




More information about the asterisk-commits mailing list