summaryrefslogtreecommitdiff
path: root/proto_bin.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-01-09 18:08:26 -0800
committerdormando <dormando@rydia.net>2023-01-11 13:24:22 -0800
commitfccf7b9efdfb0deb11f111496ce53c5892647dab (patch)
treea3c2f6bafee2d80a609806627bd3922e0aa6cd08 /proto_bin.c
parent8bb9d9a3e5ca93c38db97181d4c15b03d48a644d (diff)
downloadmemcached-fccf7b9efdfb0deb11f111496ce53c5892647dab.tar.gz
core: remove *conn object from cache commands
We want to start using cache commands in contexts without a client connection, but the client object has always been passed to all functions. In most cases we only need the worker thread (LIBEVENT_THREAD *t), so this change adjusts the arguments passed in.
Diffstat (limited to 'proto_bin.c')
-rw-r--r--proto_bin.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/proto_bin.c b/proto_bin.c
index d8b37c5..0a30b8a 100644
--- a/proto_bin.c
+++ b/proto_bin.c
@@ -294,7 +294,7 @@ static void complete_incr_bin(conn *c, char *extbuf) {
if (c->binary_header.request.cas != 0) {
cas = c->binary_header.request.cas;
}
- switch(add_delta(c, key, nkey, c->cmd == PROTOCOL_BINARY_CMD_INCREMENT,
+ switch(add_delta(c->thread, key, nkey, c->cmd == PROTOCOL_BINARY_CMD_INCREMENT,
req->message.body.delta, tmpbuf,
&cas)) {
case OK:
@@ -323,11 +323,13 @@ static void complete_incr_bin(conn *c, char *extbuf) {
res + 2);
if (it != NULL) {
+ uint64_t cas = 0;
memcpy(ITEM_data(it), tmpbuf, res);
memcpy(ITEM_data(it) + res, "\r\n", 2);
+ c->thread->cur_sfd = c->sfd; // for store_item logging.
- if (store_item(it, NREAD_ADD, c)) {
- c->cas = ITEM_get_cas(it);
+ if (store_item(it, NREAD_ADD, c->thread, &cas, CAS_NO_STALE)) {
+ c->cas = cas;
write_bin_response(c, &rsp->message.body, 0, 0, sizeof(rsp->message.body.value));
} else {
write_bin_error(c, PROTOCOL_BINARY_RESPONSE_NOT_STORED,
@@ -382,7 +384,10 @@ static void complete_update_bin(conn *c) {
ch->used += 2;
}
- ret = store_item(it, c->cmd, c);
+ uint64_t cas = 0;
+ c->thread->cur_sfd = c->sfd; // for store_item logging.
+ ret = store_item(it, c->cmd, c->thread, &cas, CAS_NO_STALE);
+ c->cas = cas;
#ifdef ENABLE_DTRACE
uint64_t cas = ITEM_get_cas(it);
@@ -476,9 +481,9 @@ static void process_bin_get_or_touch(conn *c, char *extbuf) {
protocol_binary_request_touch *t = (void *)extbuf;
time_t exptime = ntohl(t->message.body.expiration);
- it = item_touch(key, nkey, realtime(exptime), c);
+ it = item_touch(key, nkey, realtime(exptime), c->thread);
} else {
- it = item_get(key, nkey, c, DO_UPDATE);
+ it = item_get(key, nkey, c->thread, DO_UPDATE);
}
if (it) {
@@ -888,6 +893,7 @@ static void dispatch_bin_command(conn *c, char *extbuf) {
uint8_t extlen = c->binary_header.request.extlen;
uint16_t keylen = c->binary_header.request.keylen;
uint32_t bodylen = c->binary_header.request.bodylen;
+ c->thread->cur_sfd = c->sfd; // cuddle sfd for logging.
if (keylen > bodylen || keylen + extlen > bodylen) {
write_bin_error(c, PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND, NULL, 0);
@@ -1136,7 +1142,7 @@ static void process_bin_update(conn *c, char *extbuf) {
/* Avoid stale data persisting in cache because we failed alloc.
* Unacceptable for SET. Anywhere else too? */
if (c->cmd == PROTOCOL_BINARY_CMD_SET) {
- it = item_get(key, nkey, c, DONT_UPDATE);
+ it = item_get(key, nkey, c->thread, DONT_UPDATE);
if (it) {
item_unlink(it);
STORAGE_delete(c->thread->storage, it);
@@ -1303,7 +1309,7 @@ static void process_bin_delete(conn *c) {
stats_prefix_record_delete(key, nkey);
}
- it = item_get_locked(key, nkey, c, DONT_UPDATE, &hv);
+ it = item_get_locked(key, nkey, c->thread, DONT_UPDATE, &hv);
if (it) {
uint64_t cas = c->binary_header.request.cas;
if (cas == 0 || cas == ITEM_get_cas(it)) {