From e78938425536748e63932ccebb7248f6389db102 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Mon, 23 Dec 2013 12:48:39 +0100
Subject: [PATCH] Fix CONFIG REWRITE handling of unknown options.

There were two problems with the implementation.

1) "save" was not correctly processed when no save point was configured,
   as reported in issue #1416.
2) The way the code checked if an option existed in the "processed"
   dictionary was wrong, as we add the element with as a key associated
   with a NULL value, so dictFetchValue() can't be used to check for
   existance, but dictFind() must be used, that returns NULL only if the
   entry does not exist at all.
---
 src/config.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/config.c b/src/config.c
index 3bd1d859..d01b3e81 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1440,6 +1440,8 @@ void rewriteConfigSaveOption(struct rewriteConfigState *state) {
             server.saveparams[j].seconds, server.saveparams[j].changes);
         rewriteConfigRewriteLine(state,"save",line,1);
     }
+    /* Mark "save" as processed in case server.saveparamslen is zero. */
+    rewriteConfigMarkAsProcessed(state,"save");
 }
 
 /* Rewrite the dir option, always using absolute paths.*/
@@ -1578,7 +1580,7 @@ void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) {
 
         /* Don't blank lines about options the rewrite process
          * don't understand. */
-        if (dictFetchValue(state->rewritten,option) == NULL) {
+        if (dictFind(state->rewritten,option) == NULL) {
             redisLog(REDIS_DEBUG,"Not rewritten option: %s", option);
             continue;
         }