summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2011-12-12 16:49:59 -0800
committerdormando <dormando@rydia.net>2011-12-12 16:49:59 -0800
commit7066273828c42ccdd76dda1880b0accc7abf1f31 (patch)
tree714a5730ecc57ef95a678e86cdb6e6ab4a0c5c9f
parentee486ab2990877e384bd993f330aafea795c1397 (diff)
downloadmemcached-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.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/items.c b/items.c
index ebd2cb5..c105fdc 100644
--- a/items.c
+++ b/items.c
@@ -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;
}