summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-06-25 17:50:45 +0200
committerantirez <antirez@gmail.com>2018-06-25 17:50:46 +0200
commitfc0c9c8097a5b2bc8728bec9cfee26817a702f09 (patch)
treec805809493c5f7e77616e45041caf58d5dd7fa6c
parent8ba670f55c88c0412e5646e35cf02fda655b8ed8 (diff)
downloadredis-fc0c9c8097a5b2bc8728bec9cfee26817a702f09.tar.gz
Sentinel: drop the renamed-command entry in a more natural way.
Instead of telling the user to set the renamed command to "" to remove the renaming, to the obvious thing when a command is renamed to itself. So if I want to remove the renaming of PING, I just rename it to PING again.
-rw-r--r--src/sentinel.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index de49cdebb..18743e91d 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -3469,19 +3469,16 @@ void sentinelSetCommand(client *c) {
ri->quorum = ll;
changes++;
} else if (!strcasecmp(option,"rename-command") && moreargs > 1) {
- /* rename-command <oldname> <newname>
- *
- * Note: if newname is the empty string the command renaming
- * entry is deleted. */
+ /* rename-command <oldname> <newname> */
sds oldname = c->argv[++j]->ptr;
sds newname = c->argv[++j]->ptr;
/* Remove any older renaming for this command. */
dictDelete(ri->renamed_commands,oldname);
- /* If the target name length is not zero, we need to add the
- * actual entry to the renamed table. */
- if (sdslen(newname)) {
+ /* If the target name is the same as the source name there
+ * is no need to add an entry mapping to itself. */
+ if (!dictSdsKeyCaseCompare(NULL,oldname,newname)) {
oldname = sdsdup(oldname);
newname = sdsdup(newname);
dictAdd(ri->renamed_commands,oldname,newname);