diff options
author | Akira TAGOH <akira@tagoh.org> | 2017-11-24 10:53:39 +0530 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2017-11-24 10:53:39 +0530 |
commit | 1b2279d6b5118fc00bc028340d14fe1e345a4ab4 (patch) | |
tree | ff1b5a797b7071830267842bc26ef3c17445bfc1 /src | |
parent | 4758144492cf694b9d762733bc0907c0dad5b34d (diff) |
thread-safe functions in fchash.c
Diffstat (limited to 'src')
-rw-r--r-- | src/fchash.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/fchash.c b/src/fchash.c index 7a320d5d..9857abc4 100644 --- a/src/fchash.c +++ b/src/fchash.c @@ -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; } |