Use correct release semantic in list update.

nscd uses lockfree lists and we need to ensure the correct release
semantics is used when adding to the list.
This commit is contained in:
Andreas Schwab 2009-07-16 09:57:32 -07:00 committed by Ulrich Drepper
parent bec466d922
commit 50158f9552
2 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,10 @@
2009-07-16 Ulrich Drepper <drepper@redhat.com> 2009-07-16 Ulrich Drepper <drepper@redhat.com>
* nscd/cache.c (cache_add): Use atomic_compare_and_exchange_bool_rel
instead of atomic_compare_and_exchange_bool_acq to ensure pointer
is written before the list head update.
Patch by Andreas Schwab <aschwab@redhat.com>.
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
* malloc/malloc.c [ATOMIC_FASTBINS] (_int_free): Make check for * malloc/malloc.c [ATOMIC_FASTBINS] (_int_free): Make check for

View File

@ -179,7 +179,7 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet,
/* Put the new entry in the first position. */ /* Put the new entry in the first position. */
do do
newp->next = table->head->array[hash]; newp->next = table->head->array[hash];
while (atomic_compare_and_exchange_bool_acq (&table->head->array[hash], while (atomic_compare_and_exchange_bool_rel (&table->head->array[hash],
(ref_t) ((char *) newp (ref_t) ((char *) newp
- table->data), - table->data),
(ref_t) newp->next)); (ref_t) newp->next));