summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-11-19 17:58:11 +0100
committerantirez <antirez@gmail.com>2013-11-19 17:58:11 +0100
commitb1f5a0b3ece05de66b22e7544c63ac7659b6d06b (patch)
tree1e126cd6ac2c7d775bf2ad32b9edb42d48ac6ef9 /src
parent37a51a2568ed8558c60920e1bc08dd5265e74efe (diff)
downloadredis-b1f5a0b3ece05de66b22e7544c63ac7659b6d06b.tar.gz
CONFIG REWRITE: don't add the signature if it already exists.
At the end of the file, CONFIG REWRITE adds a comment line that: # Generated by CONFIG REWRITE Followed by the additional config options required. However this was added again and again at every rewrite in praticular conditions (when a given set of options change in a given time during the time). Now if it was alrady encountered, it is not added a second time. This is especially important for Sentinel that rewrites the config at every state change.
Diffstat (limited to 'src')
-rw-r--r--src/config.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c
index d39546e13..4f7ddda98 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1154,6 +1154,8 @@ void configGetCommand(redisClient *c) {
*
*/
+#define REDIS_CONFIG_REWRITE_SIGNATURE "# Generated by CONFIG REWRITE"
+
/* We use the following dictionary type to store where a configuration
* option is mentioned in the old configuration file, so it's
* like "maxmemory" -> list of line numbers (first line is zero). */
@@ -1230,6 +1232,8 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) {
/* Handle comments and empty lines. */
if (line[0] == '#' || line[0] == '\0') {
+ if (!state->has_tail && !strcmp(line,REDIS_CONFIG_REWRITE_SIGNATURE))
+ state->has_tail = 1;
rewriteConfigAppendLine(state,line);
continue;
}
@@ -1301,7 +1305,7 @@ void rewriteConfigRewriteLine(struct rewriteConfigState *state, char *option, sd
/* Append a new line. */
if (!state->has_tail) {
rewriteConfigAppendLine(state,
- sdsnew("# Generated by CONFIG REWRITE"));
+ sdsnew(REDIS_CONFIG_REWRITE_SIGNATURE));
state->has_tail = 1;
}
rewriteConfigAppendLine(state,line);