diff options
author | dormando <dormando@rydia.net> | 2011-12-12 16:49:59 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2011-12-12 16:49:59 -0800 |
commit | 7066273828c42ccdd76dda1880b0accc7abf1f31 (patch) | |
tree | 714a5730ecc57ef95a678e86cdb6e6ab4a0c5c9f | |
parent | ee486ab2990877e384bd993f330aafea795c1397 (diff) | |
download | memcached-7066273828c42ccdd76dda1880b0accc7abf1f31.tar.gz |
shorten lock for item allocation more
after pulling an item off of the LRU, there's no reason to hold the cache lock
while we initialize a few values and memcpy some junk.
-rw-r--r-- | items.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -181,11 +181,14 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim } assert(it->slabs_clsid == 0); + assert(it != heads[id]); + /* Item initialization can happen outside of the lock; the item's already + * been removed from the slab LRU. + */ + pthread_mutex_unlock(&cache_lock); it->slabs_clsid = id; - assert(it != heads[it->slabs_clsid]); - it->next = it->prev = it->h_next = 0; it->refcount = 1; /* the caller will have a reference */ DEBUG_REFCNT(it, '*'); @@ -196,7 +199,6 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim it->exptime = exptime; memcpy(ITEM_suffix(it), suffix, (size_t)nsuffix); it->nsuffix = nsuffix; - pthread_mutex_unlock(&cache_lock); return it; } |