thread-safe functions in fchash.c

This commit is contained in:
Akira TAGOH 2017-11-24 10:53:39 +05:30
parent 4758144492
commit 1b2279d6b5
1 changed files with 4 additions and 2 deletions

View File

@ -169,13 +169,15 @@ FcHashTableAdd (FcHashTable *table,
return !ret;
}
retry:
for (prev = &table->buckets[hash % FC_HASH_SIZE];
(b = *prev); prev = &(b->next))
(b = fc_atomic_ptr_get (prev)); prev = &(b->next))
{
if (!table->compare_func (bucket->key, key))
goto destroy;
}
*prev = bucket;
if (!fc_atomic_ptr_cmpexch (prev, b, bucket))
goto retry;
return FcTrue;
}