[svn-commits] rmudgett: branch rmudgett/ao2_enhancements r370741 - /team/rmudgett/ao2_enhan...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 2 11:08:42 CDT 2012


Author: rmudgett
Date: Thu Aug  2 11:08:39 2012
New Revision: 370741

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=370741
Log:
* Assert that the hash container becomes empty when destroying it.

* Change the reg_containers container to replace duplicates instead of
rejecting them.  You can now re-register the same name with new
containers instead of unregistering the old one first.

* Clean up some comments.

Modified:
    team/rmudgett/ao2_enhancements/main/astobj2.c

Modified: team/rmudgett/ao2_enhancements/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ao2_enhancements/main/astobj2.c?view=diff&rev=370741&r1=370740&r2=370741
==============================================================================
--- team/rmudgett/ao2_enhancements/main/astobj2.c (original)
+++ team/rmudgett/ao2_enhancements/main/astobj2.c Thu Aug  2 11:08:39 2012
@@ -1378,7 +1378,6 @@
 /*!
  * A structure to create a linked list of entries,
  * used within a bucket.
- * XXX \todo this should be private to the container code
  */
 struct hash_bucket_node {
 	/*! Next node links in the list. */
@@ -2052,6 +2051,20 @@
 		}
 	}
 
+#if defined(AST_DEVMODE)
+	if (self->common.destroying) {
+		/* Check that the container no longer has any nodes */
+		for (i = self->n_buckets; i--;) {
+			if (!AST_DLLIST_EMPTY(&self->buckets[i].list)) {
+				ast_log(LOG_ERROR,
+					"Ref leak destroying container.  Container still has nodes!\n");
+				ast_assert(0);
+				break;
+			}
+		}
+	}
+#endif	/* defined(AST_DEVMODE) */
+
 	if (flags & OBJ_NOLOCK) {
 		adjust_lock(self, orig_lock, 0);
 	} else {
@@ -2306,8 +2319,6 @@
 	unsigned int container_options, unsigned int n_buckets, ao2_hash_fn *hash_fn,
 	ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn)
 {
-	/* XXX maybe consistency check on arguments ? */
-	/* compute the container size */
 	unsigned int num_buckets;
 	size_t container_size;
 	struct ao2_container_hash *self;
@@ -2325,8 +2336,6 @@
 	ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn,
 	const char *tag, const char *file, int line, const char *func, int ref_debug)
 {
-	/* XXX maybe consistency check on arguments ? */
-	/* compute the container size */
 	unsigned int num_buckets;
 	size_t container_size;
 	struct ao2_container_hash *self;
@@ -2741,7 +2750,7 @@
 {
 #if defined(AST_DEVMODE)
 	reg_containers = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_RWLOCK,
-		AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, ao2_reg_sort_cb, NULL);
+		AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ao2_reg_sort_cb, NULL);
 #endif	/* defined(AST_DEVMODE) */
 #if defined(AO2_DEBUG) || defined(AST_DEVMODE)
 	ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));




More information about the svn-commits mailing list