From fc0c9c8097a5b2bc8728bec9cfee26817a702f09 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 25 Jun 2018 17:50:45 +0200 Subject: [PATCH] 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. --- src/sentinel.c | 11 ++++------- 1 file 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 - * - * Note: if newname is the empty string the command renaming - * entry is deleted. */ + /* rename-command */ 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);