summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2022-09-27 22:09:22 -0700
committerdormando <dormando@rydia.net>2022-10-20 14:43:53 -0700
commit493bb69af53f3e34ba87ad002c4a9f6c49470b2b (patch)
tree131349984d57b58a1f7fea8560c966e20c0767f4
parentcedaf5586883ffd2323307f45f90f4d70e94ecc2 (diff)
downloadmemcached-493bb69af53f3e34ba87ad002c4a9f6c49470b2b.tar.gz
meta: remove excess spaces from meta responses
was returning "HD \r\n" and "HD Oetc\r\n" - not to protocol spec.
-rw-r--r--proto_text.c16
-rw-r--r--t/metaget.t10
2 files changed, 17 insertions, 9 deletions
diff --git a/proto_text.c b/proto_text.c
index dc6c624..ab1130f 100644
--- a/proto_text.c
+++ b/proto_text.c
@@ -1560,8 +1560,8 @@ static void process_mdelete_command(conn *c, token_t *tokens, const size_t ntoke
char *errstr = "CLIENT_ERROR bad command line format";
assert(c != NULL);
mc_resp *resp = c->resp;
- // reserve 3 bytes for status code
- char *p = resp->wbuf + 3;
+ // reserve bytes for status code
+ char *p = resp->wbuf + 2;
WANT_TOKENS_MIN(ntokens, 3);
@@ -1617,7 +1617,7 @@ static void process_mdelete_command(conn *c, token_t *tokens, const size_t ntoke
c->thread->stats.delete_misses++;
pthread_mutex_unlock(&c->thread->stats.mutex);
- memcpy(resp->wbuf, "EX ", 3);
+ memcpy(resp->wbuf, "EX", 2);
goto cleanup;
}
@@ -1638,9 +1638,9 @@ static void process_mdelete_command(conn *c, token_t *tokens, const size_t ntoke
if (c->noreply)
resp->skip = true;
if (settings.meta_response_old) {
- memcpy(resp->wbuf, "OK ", 3);
+ memcpy(resp->wbuf, "OK", 2);
} else {
- memcpy(resp->wbuf, "HD ", 3);
+ memcpy(resp->wbuf, "HD", 2);
}
} else {
pthread_mutex_lock(&c->thread->stats.mutex);
@@ -1652,9 +1652,9 @@ static void process_mdelete_command(conn *c, token_t *tokens, const size_t ntoke
if (c->noreply)
resp->skip = true;
if (settings.meta_response_old) {
- memcpy(resp->wbuf, "OK ", 3);
+ memcpy(resp->wbuf, "OK", 2);
} else {
- memcpy(resp->wbuf, "HD ", 3);
+ memcpy(resp->wbuf, "HD", 2);
}
}
goto cleanup;
@@ -1663,7 +1663,7 @@ static void process_mdelete_command(conn *c, token_t *tokens, const size_t ntoke
c->thread->stats.delete_misses++;
pthread_mutex_unlock(&c->thread->stats.mutex);
- memcpy(resp->wbuf, "NF ", 3);
+ memcpy(resp->wbuf, "NF", 2);
goto cleanup;
}
cleanup:
diff --git a/t/metaget.t b/t/metaget.t
index 6ea17ca..06f1623 100644
--- a/t/metaget.t
+++ b/t/metaget.t
@@ -129,6 +129,14 @@ my $sock = $server->sock;
like(scalar <$sock>, qr/^ME foo /, "raw mget result");
}
+# mdelete had excess space before newline.
+{
+ print $sock "md deltest\r\n";
+ is(scalar <$sock>, "NF\r\n", "delete status is correct");
+ print $sock "md foo\r\n";
+ is(scalar <$sock>, "HD\r\n", "delete status is correct");
+}
+
# mget with arguments
# - set some specific TTL and get it back (within reason)
# - get cas
@@ -499,7 +507,7 @@ my $sock = $server->sock;
# Lets mark the sucker as invalid, and drop its TTL to 30s
diag "running mdelete";
print $sock "md toinv I T30\r\n";
- like(scalar <$sock>, qr/^HD /, "mdelete'd key");
+ like(scalar <$sock>, qr/^HD/, "mdelete'd key");
# TODO: decide on if we need an explicit flag for "if I fetched a stale
# value, does winning matter?