Commit b3dc23c5 authored by xhe's avatar xhe
Browse files

add a read-only variant for HELLO

As discussed in https://github.com/antirez/redis/issues/7364, it is good
to have a HELLO command variant, which does not switch the current proto
version of a redis server.

While `HELLO` will work, it introduced a certain difficulty on parsing
options of the command. We will need to offset the index of authentication
and setname option by -1.

So 0 is marked a special version meaning non-switching. And we do not
need to change the code much.
parent 59ff42c4
......@@ -2763,7 +2763,7 @@ void helloCommand(client *c) {
long long ver;
if (getLongLongFromObject(c->argv[1],&ver) != C_OK ||
ver < 2 || ver > 3)
(ver != 0 && ver < 2) || ver > 3)
{
addReplyError(c,"-NOPROTO unsupported protocol version");
return;
......@@ -2797,7 +2797,7 @@ void helloCommand(client *c) {
}
/* Let's switch to the specified RESP mode. */
c->resp = ver;
if (ver != 0) c->resp = ver;
addReplyMapLen(c,6 + !server.sentinel_mode);
addReplyBulkCString(c,"server");
......@@ -2807,7 +2807,7 @@ void helloCommand(client *c) {
addReplyBulkCString(c,REDIS_VERSION);
addReplyBulkCString(c,"proto");
addReplyLongLong(c,ver);
addReplyLongLong(c,c->resp);
addReplyBulkCString(c,"id");
addReplyLongLong(c,c->id);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment