summaryrefslogtreecommitdiff
path: root/storage.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2020-10-20 17:16:05 -0700
committerdormando <dormando@rydia.net>2020-10-30 15:50:12 -0700
commit5d4785936e3e8937047daafd874c792668dc8528 (patch)
treeb39b15e5369faea0c2cf9b13e2613a2ed13ecf7e /storage.c
parent1ca5cdce9d403b4130e35dc1c99c6a1ea15f946f (diff)
downloadmemcached-5d4785936e3e8937047daafd874c792668dc8528.tar.gz
queue: replace c->io_pending to avoid a mutex
since multiple queues can be sent to different sidethreads, we need a new mechanism for knowing when to return everything. In the common case only one queue will be active, so adding a mutex would be excessive.
Diffstat (limited to 'storage.c')
-rw-r--r--storage.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/storage.c b/storage.c
index cfa0206..3c0af88 100644
--- a/storage.c
+++ b/storage.c
@@ -220,14 +220,13 @@ static void _storage_get_item_cb(void *e, obj_io *io, int ret) {
p->miss = false;
}
- c->io_pending--;
+ p->q->count--;
p->active = false;
//assert(c->io_wrapleft >= 0);
// All IO's have returned, lets re-attach this connection to our original
// thread.
- if (c->io_pending == 0) {
- assert(c->io_queued == true);
+ if (p->q->count == 0) {
redispatch_conn(c);
}
}
@@ -256,7 +255,6 @@ int storage_get_item(conn *c, item *it, mc_resp *resp) {
}
if (new_it == NULL)
return -1;
- assert(!c->io_queued); // FIXME: debugging.
// so we can free the chunk on a miss
new_it->slabs_clsid = clsid;
@@ -336,8 +334,8 @@ int storage_get_item(conn *c, item *it, mc_resp *resp) {
q->stack_ctx = eio;
// No need to stack the io_pending's together as they live on mc_resp's.
- assert(c->io_pending >= 0);
- c->io_pending++;
+ assert(q->count >= 0);
+ q->count++;
// reference ourselves for the callback.
eio->data = (void *)p;
@@ -386,8 +384,8 @@ static void recache_or_free(io_pending_t *pending) {
do_free = false;
size_t ntotal = ITEM_ntotal(p->hdr_it);
slabs_free(it, ntotal, slabs_clsid(ntotal));
- c->io_pending--;
- assert(c->io_pending >= 0);
+ p->q->count--;
+ assert(p->q->count >= 0);
pthread_mutex_lock(&c->thread->stats.mutex);
c->thread->stats.get_aborted_extstore++;
pthread_mutex_unlock(&c->thread->stats.mutex);