summaryrefslogtreecommitdiff
path: root/proto_text.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2021-06-09 15:09:53 -0700
committerdormando <dormando@rydia.net>2021-06-10 11:24:15 -0700
commit6a1802cb2a180971c328d9820df23336eec72c0f (patch)
treeb90933420ae79f7e6e95389bdf503f4c73c8c738 /proto_text.c
parent3d178cfd3241764acb789c166f1b0209457f2aff (diff)
downloadmemcached-6a1802cb2a180971c328d9820df23336eec72c0f.tar.gz
meta: response code OK -> HD
I had the response code as "HD" in the past, but standardized on OK while merging a number of "OK-like" rescodes together. This was a mistake; as many "generic" memcached response codes use "OK". Most of these are management or specialized uncommon commands. With this, a client response parser can know for sure if a response is to a meta command, or some other command. `-o meta_response_old` starttime option has been added, valid for the next 3 months, which switches the response code back from HD to OK. In case any existing users depended on this and need time to migrate.
Diffstat (limited to 'proto_text.c')
-rw-r--r--proto_text.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/proto_text.c b/proto_text.c
index f572a7a..22be817 100644
--- a/proto_text.c
+++ b/proto_text.c
@@ -60,7 +60,11 @@ static void _finalize_mset(conn *c, enum store_item_type ret) {
switch (ret) {
case STORED:
- memcpy(p, "OK", 2);
+ if (settings.meta_response_old) {
+ memcpy(p, "OK", 2);
+ } else {
+ memcpy(p, "HD", 2);
+ }
// Only place noreply is used for meta cmds is a nominal response.
if (c->noreply) {
resp->skip = true;
@@ -1129,7 +1133,11 @@ static void process_mget_command(conn *c, token_t *tokens, const size_t ntokens)
memcpy(p, "VA ", 3);
p = itoa_u32(it->nbytes-2, p+3);
} else {
- memcpy(p, "OK", 2);
+ if (settings.meta_response_old) {
+ memcpy(p, "OK", 2);
+ } else {
+ memcpy(p, "HD", 2);
+ }
p += 2;
}
@@ -1615,7 +1623,11 @@ static void process_mdelete_command(conn *c, token_t *tokens, const size_t ntoke
// Clients can noreply nominal responses.
if (c->noreply)
resp->skip = true;
- memcpy(resp->wbuf, "OK ", 3);
+ if (settings.meta_response_old) {
+ memcpy(resp->wbuf, "OK ", 3);
+ } else {
+ memcpy(resp->wbuf, "HD ", 3);
+ }
} else {
pthread_mutex_lock(&c->thread->stats.mutex);
c->thread->stats.slab_stats[ITEM_clsid(it)].delete_hits++;
@@ -1625,7 +1637,11 @@ static void process_mdelete_command(conn *c, token_t *tokens, const size_t ntoke
STORAGE_delete(c->thread->storage, it);
if (c->noreply)
resp->skip = true;
- memcpy(resp->wbuf, "OK ", 3);
+ if (settings.meta_response_old) {
+ memcpy(resp->wbuf, "OK ", 3);
+ } else {
+ memcpy(resp->wbuf, "HD ", 3);
+ }
}
goto cleanup;
} else {
@@ -1728,7 +1744,11 @@ static void process_marithmetic_command(conn *c, token_t *tokens, const size_t n
case OK:
if (c->noreply)
resp->skip = true;
- memcpy(resp->wbuf, "OK ", 3);
+ if (settings.meta_response_old) {
+ memcpy(resp->wbuf, "OK ", 3);
+ } else {
+ memcpy(resp->wbuf, "HD ", 3);
+ }
break;
case NON_NUMERIC:
errstr = "CLIENT_ERROR cannot increment or decrement non-numeric value";
@@ -1786,7 +1806,11 @@ static void process_marithmetic_command(conn *c, token_t *tokens, const size_t n
memcpy(p, "VA ", 3);
p = itoa_u32(vlen, p+3);
} else {
- memcpy(p, "OK", 2);
+ if (settings.meta_response_old) {
+ memcpy(p, "OK", 2);
+ } else {
+ memcpy(p, "HD", 2);
+ }
p += 2;
}