Skip to content

Commit

Permalink
Extend memory unit support in CONFIG SET.
Browse files Browse the repository at this point in the history
Related to PR redis#2357.
  • Loading branch information
antirez committed Feb 12, 2015
1 parent 304aa59 commit 9e6155f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ void loadServerConfig(char *filename, char *options) {
void configSetCommand(redisClient *c) {
robj *o;
long long ll;
int err;
redisAssertWithInfo(c,c->argv[2],sdsEncodedObject(c->argv[2]));
redisAssertWithInfo(c,c->argv[3],sdsEncodedObject(c->argv[3]));
o = c->argv[3];
Expand All @@ -628,7 +629,6 @@ void configSetCommand(redisClient *c) {
zfree(server.masterauth);
server.masterauth = ((char*)o->ptr)[0] ? zstrdup(o->ptr) : NULL;
} else if (!strcasecmp(c->argv[2]->ptr,"maxmemory")) {
int err;
ll = memtoll(o->ptr,&err);
if (err || ll < 0) goto badfmt;
server.maxmemory = ll;
Expand Down Expand Up @@ -852,7 +852,6 @@ void configSetCommand(redisClient *c) {
* whole configuration string or accept it all, even if a single
* error in a single client class is present. */
for (j = 0; j < vlen; j++) {
char *eptr;
long val;

if ((j % 4) == 0) {
Expand All @@ -861,8 +860,8 @@ void configSetCommand(redisClient *c) {
goto badfmt;
}
} else {
val = strtoll(v[j], &eptr, 10);
if (eptr[0] != '\0' || val < 0) {
val = memtoll(v[j], &err);
if (err || val < 0) {
sdsfreesplitres(v,vlen);
goto badfmt;
}
Expand Down Expand Up @@ -896,7 +895,8 @@ void configSetCommand(redisClient *c) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll <= 0) goto badfmt;
server.repl_timeout = ll;
} else if (!strcasecmp(c->argv[2]->ptr,"repl-backlog-size")) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll <= 0) goto badfmt;
ll = memtoll(o->ptr,&err);
if (err || ll < 0) goto badfmt;
resizeReplicationBacklog(ll);
} else if (!strcasecmp(c->argv[2]->ptr,"repl-backlog-ttl")) {
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
Expand Down

0 comments on commit 9e6155f

Please sign in to comment.