diff options
Diffstat (limited to 'items.c')
-rw-r--r-- | items.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -104,7 +104,7 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim rel_time_t oldest_live = settings.oldest_live; search = tails[id]; - if (search != NULL && (__sync_add_and_fetch(&search->refcount, 1) == 2)) { + if (search != NULL && (refcount_incr(&search->refcount) == 2)) { if ((search->exptime != 0 && search->exptime < current_time) || (search->time < oldest_live)) { // dead by flush STATS_LOCK(); @@ -147,13 +147,13 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim /* Initialize the item block: */ it->slabs_clsid = 0; } else { - __sync_sub_and_fetch(&search->refcount, 1); + refcount_decr(&search->refcount); } } else { /* If the LRU is empty or locked, attempt to allocate memory */ it = slabs_alloc(ntotal, id); if (search != NULL) - __sync_sub_and_fetch(&search->refcount, 1); + refcount_decr(&search->refcount); } if (it == NULL) { @@ -287,7 +287,7 @@ int do_item_link(item *it, const uint32_t hv) { ITEM_set_cas(it, (settings.use_cas) ? get_cas_id() : 0); assoc_insert(it, hv); item_link_q(it); - __sync_add_and_fetch(&it->refcount, 1); + refcount_incr(&it->refcount); pthread_mutex_unlock(&cache_lock); return 1; @@ -328,7 +328,7 @@ void do_item_remove(item *it) { MEMCACHED_ITEM_REMOVE(ITEM_key(it), it->nkey, it->nbytes); assert((it->it_flags & ITEM_SLABBED) == 0); - if (__sync_sub_and_fetch(&it->refcount, 1) == 0) { + if (refcount_decr(&it->refcount) == 0) { item_free(it); } } @@ -484,7 +484,7 @@ item *do_item_get(const char *key, const size_t nkey, const uint32_t hv) { mutex_lock(&cache_lock); item *it = assoc_find(key, nkey, hv); if (it != NULL) { - __sync_add_and_fetch(&it->refcount, 1); + refcount_incr(&it->refcount); /* Optimization for slab reassignment. prevents popular items from * jamming in busy wait. Can only do this here to satisfy lock order * of item_lock, cache_lock, slabs_lock. */ |