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.
This commit is contained in:
parent
b625554f32
commit
e3cedbb18c
@ -2763,7 +2763,7 @@ void helloCommand(client *c) {
|
|||||||
long long ver;
|
long long ver;
|
||||||
|
|
||||||
if (getLongLongFromObject(c->argv[1],&ver) != C_OK ||
|
if (getLongLongFromObject(c->argv[1],&ver) != C_OK ||
|
||||||
ver < 2 || ver > 3)
|
(ver != 0 && ver < 2) || ver > 3)
|
||||||
{
|
{
|
||||||
addReplyError(c,"-NOPROTO unsupported protocol version");
|
addReplyError(c,"-NOPROTO unsupported protocol version");
|
||||||
return;
|
return;
|
||||||
@ -2797,7 +2797,7 @@ void helloCommand(client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Let's switch to the specified RESP mode. */
|
/* Let's switch to the specified RESP mode. */
|
||||||
c->resp = ver;
|
if (ver != 0) c->resp = ver;
|
||||||
addReplyMapLen(c,6 + !server.sentinel_mode);
|
addReplyMapLen(c,6 + !server.sentinel_mode);
|
||||||
|
|
||||||
addReplyBulkCString(c,"server");
|
addReplyBulkCString(c,"server");
|
||||||
@ -2807,7 +2807,7 @@ void helloCommand(client *c) {
|
|||||||
addReplyBulkCString(c,REDIS_VERSION);
|
addReplyBulkCString(c,REDIS_VERSION);
|
||||||
|
|
||||||
addReplyBulkCString(c,"proto");
|
addReplyBulkCString(c,"proto");
|
||||||
addReplyLongLong(c,ver);
|
addReplyLongLong(c,c->resp);
|
||||||
|
|
||||||
addReplyBulkCString(c,"id");
|
addReplyBulkCString(c,"id");
|
||||||
addReplyLongLong(c,c->id);
|
addReplyLongLong(c,c->id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user