[asterisk-commits] rmudgett: branch rmudgett/ao2_red_black r371820 - /team/rmudgett/ao2_red_blac...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 28 12:06:18 CDT 2012


Author: rmudgett
Date: Tue Aug 28 12:06:14 2012
New Revision: 371820

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=371820
Log:
Clean-up node insertion/deletion container integrity checks.

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

Modified: team/rmudgett/ao2_red_black/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ao2_red_black/main/astobj2.c?view=diff&rev=371820&r1=371819&r2=371820
==============================================================================
--- team/rmudgett/ao2_red_black/main/astobj2.c (original)
+++ team/rmudgett/ao2_red_black/main/astobj2.c Tue Aug 28 12:06:14 2012
@@ -1039,9 +1039,25 @@
 	res = 0;
 	node = self->v_table->new_node(self, obj_new, tag, file, line, func);
 	if (node) {
-		if (ao2_container_check(self, OBJ_NOLOCK)) {/* BUGBUG */
-			ast_log(LOG_NOTICE, "BUGBUG integrity failed before insert.\n");
-		}
+#if defined(AO2_DEBUG) && defined(AST_DEVMODE)
+		switch (self->v_table->type) {
+		case AO2_CONTAINER_RTTI_HASH:
+			if (!self->sort_fn) {
+				/*
+				 * XXX chan_iax2 plays games with the hash function so we cannot
+				 * routinely do an integrity check on this type of container.
+				 * chan_iax2 should be changed to not abuse the hash function.
+				 */
+				break;
+			}
+			/* Fall through. */
+		case AO2_CONTAINER_RTTI_RBTREE:
+			if (ao2_container_check(self, OBJ_NOLOCK)) {
+				ast_log(LOG_ERROR, "Container integrity failed before insert.\n");
+			}
+			break;
+		}
+#endif	/* defined(AO2_DEBUG) && defined(AST_DEVMODE) */
 		/* Insert the new node. */
 		switch (self->v_table->insert(self, node)) {
 		case AO2_CONTAINER_INSERT_NODE_INSERTED:
@@ -1067,9 +1083,27 @@
 			__ao2_ref(node, -1);
 			break;
 		}
-		if (ao2_container_check(self, OBJ_NOLOCK)) {/* BUGBUG */
-			ast_log(LOG_NOTICE, "BUGBUG integrity failed after insert.\n");
-		}
+#if defined(AO2_DEBUG) && defined(AST_DEVMODE)
+		if (res) {
+			switch (self->v_table->type) {
+			case AO2_CONTAINER_RTTI_HASH:
+				if (!self->sort_fn) {
+					/*
+					 * XXX chan_iax2 plays games with the hash function so we cannot
+					 * routinely do an integrity check on this type of container.
+					 * chan_iax2 should be changed to not abuse the hash function.
+					 */
+					break;
+				}
+				/* Fall through. */
+			case AO2_CONTAINER_RTTI_RBTREE:
+				if (ao2_container_check(self, OBJ_NOLOCK)) {
+					ast_log(LOG_ERROR, "Container integrity failed after insert.\n");
+				}
+				break;
+			}
+		}
+#endif	/* defined(AO2_DEBUG) && defined(AST_DEVMODE) */
 	}
 
 	if (flags & OBJ_NOLOCK) {
@@ -1973,9 +2007,20 @@
 		my_container = (struct ao2_container_hash *) doomed->common.my_container;
 		adjust_lock(my_container, AO2_LOCK_REQ_WRLOCK, 1);
 
+#if defined(AO2_DEBUG) && defined(AST_DEVMODE)
+		/*
+		 * XXX chan_iax2 plays games with the hash function so we cannot
+		 * routinely do an integrity check on this type of container.
+		 * chan_iax2 should be changed to not abuse the hash function.
+		 */
+		if (!my_container->common.destroying
+			&& my_container->common.sort_fn
+			&& ao2_container_check(doomed->common.my_container, OBJ_NOLOCK)) {
+			ast_log(LOG_ERROR, "Container integrity failed before node deletion.\n");
+		}
+#endif	/* defined(AO2_DEBUG) && defined(AST_DEVMODE) */
 		bucket = &my_container->buckets[doomed->my_bucket];
 		AST_DLLIST_REMOVE(&bucket->list, doomed, links);
-
 		AO2_DEVMODE_STAT(--my_container->common.nodes);
 	}
 
@@ -3861,17 +3906,22 @@
 		my_container = (struct ao2_container_rbtree *) doomed->common.my_container;
 		adjust_lock(my_container, AO2_LOCK_REQ_WRLOCK, 1);
 
+#if defined(AO2_DEBUG) && defined(AST_DEVMODE)
 		if (!my_container->common.destroying
-			&& ao2_container_check(doomed->common.my_container, OBJ_NOLOCK)) {/* BUGBUG */
-			ast_log(LOG_NOTICE, "BUGBUG integrity failed before delete.\n");
-		}
+			&& ao2_container_check(doomed->common.my_container, OBJ_NOLOCK)) {
+			ast_log(LOG_ERROR, "Container integrity failed before node deletion.\n");
+		}
+#endif	/* defined(AO2_DEBUG) && defined(AST_DEVMODE) */
+//BUGBUG
 //		rb_dump(my_container, "Pre deletion");
 //		printf("%16p Deleting node\n", doomed);
 		rb_delete_node(my_container, doomed);
+#if defined(AO2_DEBUG) && defined(AST_DEVMODE)
 		if (!my_container->common.destroying
-			&& ao2_container_check(doomed->common.my_container, OBJ_NOLOCK)) {/* BUGBUG */
-			ast_log(LOG_NOTICE, "BUGBUG integrity failed after delete.\n");
-		}
+			&& ao2_container_check(doomed->common.my_container, OBJ_NOLOCK)) {
+			ast_log(LOG_ERROR, "Container integrity failed after node deletion.\n");
+		}
+#endif	/* defined(AO2_DEBUG) && defined(AST_DEVMODE) */
 	}
 
 	/*




More information about the asterisk-commits mailing list