Skip to content

Commit

Permalink
Update rewriteConfigSaveOption function code to rewrite multiple save…
Browse files Browse the repository at this point in the history
… in one line. (valkey-io#583)

Currently, "config rewrite" writes some default value in the config file
incase of empty config file specified.

But it adds multiple "save" config entries as follows:
```
save 3600 1
save 300 100
save 60 10000
```

After the fix the save will look like:
```
save 3600 1 300 100 60 10000
```

---------

Signed-off-by: Shivshankar-Reddy <[email protected]>
  • Loading branch information
Shivshankar-Reddy authored Jun 10, 2024
1 parent a3f1535 commit e65b2d2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1367,11 +1367,11 @@ void rewriteConfigSaveOption(standardConfig *config, const char *name, struct re
if (!server.saveparamslen) {
rewriteConfigRewriteLine(state, name, sdsnew("save \"\""), 1);
} else {
line = sdsnew(name);
for (j = 0; j < server.saveparamslen; j++) {
line = sdscatprintf(sdsempty(), "save %ld %d", (long)server.saveparams[j].seconds,
server.saveparams[j].changes);
rewriteConfigRewriteLine(state, name, line, 1);
line = sdscatprintf(line, " %ld %d", (long)server.saveparams[j].seconds, server.saveparams[j].changes);
}
rewriteConfigRewriteLine(state, name, line, 1);
}

/* Mark "save" as processed in case server.saveparamslen is zero. */
Expand Down

0 comments on commit e65b2d2

Please sign in to comment.