summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-05-13 11:26:43 +0200
committerantirez <antirez@gmail.com>2013-05-13 11:26:49 +0200
commitd95592b11689130382d7bf71aedf8963cc7f7431 (patch)
treef7117ee1afc5d7bc8376e06edd6027e8ff04a053
parent2bc31e55eedf24b7ecac0172c47006e79231dcde (diff)
downloadredis-d95592b11689130382d7bf71aedf8963cc7f7431.tar.gz
CONFIG REWRITE: support for dir and slaveof.
-rw-r--r--src/config.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 340e93d46..52c4dca1f 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1329,9 +1329,21 @@ void rewriteConfigSaveOption(struct rewriteConfigState *state) {
}
void rewriteConfigDirOption(struct rewriteConfigState *state) {
+ char cwd[1024];
+
+ if (getcwd(cwd,sizeof(cwd)) == NULL) return; /* no rewrite on error. */
+ rewriteConfigStringOption(state,"dir",cwd,NULL);
}
void rewriteConfigSlaveofOption(struct rewriteConfigState *state) {
+ sds line;
+
+ /* If this is a master, we want all the slaveof config options
+ * in the file to be removed. */
+ if (server.masterhost == NULL) return;
+ line = sdscatprintf(sdsempty(),"slaveof %s %d",
+ server.masterhost, server.masterport);
+ rewriteConfigRewriteLine(state,"slaveof",line,1);
}
void rewriteConfigAppendonlyOption(struct rewriteConfigState *state) {