diff options
author | dormando <dormando@rydia.net> | 2017-11-05 17:15:09 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-11-28 14:18:05 -0800 |
commit | b084b25b173467c381d3478f2d199cf844135212 (patch) | |
tree | 090b6d5b29f19f608146a765ca6d16e9dd8c3dbc /memcached.c | |
parent | 22ff93d040f18a532a9e185553eb442899d44e2f (diff) | |
download | memcached-b084b25b173467c381d3478f2d199cf844135212.tar.gz |
extstore: make ext_recache_rate=0 work
would divide by zero before :) now short circuits whole function.
Diffstat (limited to 'memcached.c')
-rw-r--r-- | memcached.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/memcached.c b/memcached.c index dea4e66..bdec77a 100644 --- a/memcached.c +++ b/memcached.c @@ -642,8 +642,10 @@ conn *conn_new(const int sfd, enum conn_states init_state, static void recache_or_free(conn *c, io_wrap *wrap) { item *it; it = (item *)wrap->io.buf; + bool do_free = true; // If request was ultimately a miss, unlink the header. if (wrap->miss) { + do_free = false; size_t ntotal = ITEM_ntotal(wrap->hdr_it); item_unlink(wrap->hdr_it); slabs_free(it, ntotal, slabs_clsid(ntotal)); @@ -652,10 +654,9 @@ static void recache_or_free(conn *c, io_wrap *wrap) { if (wrap->badcrc) c->thread->stats.badcrc_from_extstore++; pthread_mutex_unlock(&c->thread->stats.mutex); - } else { + } else if (settings.ext_recache_rate) { // hashvalue is cuddled during store uint32_t hv = (uint32_t)it->time; - bool do_free = true; // opt to throw away rather than wait on a lock. void *hold_lock = item_trylock(hv); if (hold_lock != NULL) { @@ -678,12 +679,12 @@ static void recache_or_free(conn *c, io_wrap *wrap) { pthread_mutex_unlock(&c->thread->stats.mutex); } } - - if (do_free) - slabs_free(it, ITEM_ntotal(it), ITEM_clsid(it)); if (hold_lock) item_trylock_unlock(hold_lock); } + if (do_free) + slabs_free(it, ITEM_ntotal(it), ITEM_clsid(it)); + wrap->io.buf = NULL; // sanity. wrap->io.next = NULL; wrap->next = NULL; |