[asterisk-commits] russell: branch 1.4 r80424 - /branches/1.4/main/astobj2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 22 17:40:27 CDT 2007

Author: russell
Date: Wed Aug 22 17:40:27 2007
New Revision: 80424

URL: http://svn.digium.com/view/asterisk?view=rev&rev=80424
When converting this code to use the list macros, I changed it so objects are
added to the head of a bucket instead of the tail.  However, while looking over
code with mmichelson, we noticed that the algorithm used in ao2_iterator_next
requires that items are added to the tail.  This wouldn't have caused any huge
problem, but it wasn't correct.  It meant that if an object was added to a
container while you were iterating it, and it was added to the same bucket that
the current element is in, then the new object would be returned by 
ao2_iterator_next, and any other objects in the bucket would be bypassed in
the traversal.


Modified: branches/1.4/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/astobj2.c?view=diff&rev=80424&r1=80423&r2=80424
--- branches/1.4/main/astobj2.c (original)
+++ branches/1.4/main/astobj2.c Wed Aug 22 17:40:27 2007
@@ -339,7 +339,7 @@
 	i %= c->n_buckets;
 	p->astobj = obj;
 	p->version = ast_atomic_fetchadd_int(&c->version, 1);
-	AST_LIST_INSERT_HEAD(&c->buckets[i], p, entry);
+	AST_LIST_INSERT_TAIL(&c->buckets[i], p, entry);
 	ast_atomic_fetchadd_int(&c->elements, 1);

More information about the asterisk-commits mailing list