[asterisk-commits] rizzo: branch rizzo/astobj2 r47518 -
/team/rizzo/astobj2/main/astobj2.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Nov 12 12:05:36 MST 2006
Author: rizzo
Date: Sun Nov 12 13:05:35 2006
New Revision: 47518
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47518
Log:
reorder operations in unlink to simplify life in the future
when we want to experiment with lock-free algorithms.
Reported by: marta carbone
Modified:
team/rizzo/astobj2/main/astobj2.c
Modified: team/rizzo/astobj2/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/main/astobj2.c?view=diff&rev=47518&r1=47517&r2=47518
==============================================================================
--- team/rizzo/astobj2/main/astobj2.c (original)
+++ team/rizzo/astobj2/main/astobj2.c Sun Nov 12 13:05:35 2006
@@ -20,7 +20,6 @@
#include "asterisk.h"
#include <assert.h>
-/* TODO: Revision: ? */
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <unistd.h> /* sleep, only for debugging */
@@ -440,7 +439,8 @@
struct bucket_list *x = cur;
// ast_verbose("++ unlink u %p at %p\n", EXTERNAL_OBJ(cur->astobj), cur);
- ao2_ref(EXTERNAL_OBJ(cur->astobj), -1);
+ /* we are going to modify the container, so update version */
+ ast_atomic_fetchadd_int(&c->version, 1);
if (prev == NULL) /* gone from head */
c->buckets[i].head = cur->next;
else /* gone from the middle */
@@ -448,10 +448,10 @@
if (c->buckets[i].tail == cur) /* update tail if needed */
c->buckets[i].tail = prev;
cur = cur->next ; /* prepare for next cycle */
- free(x); /* free the link record */
/* update number of elements and version */
ast_atomic_fetchadd_int(&c->elements, -1);
- ast_atomic_fetchadd_int(&c->version, 1);
+ free(x); /* free the link record */
+ ao2_ref(EXTERNAL_OBJ(cur->astobj), -1);
} else { /* prepare for next cycle */
prev = cur;
cur = cur->next;
More information about the asterisk-commits
mailing list