diff options
author | antirez <antirez@gmail.com> | 2015-02-12 16:51:20 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-02-12 16:51:20 +0100 |
commit | cd4e0f43dfa02f718ee2e836ea96bd262c4cf28e (patch) | |
tree | 089a3de9903e34b50069b0b3820a125d48285375 | |
parent | 866b3fc0ec5c61fc3504df2b15445e79437a6b78 (diff) | |
download | redis-cd4e0f43dfa02f718ee2e836ea96bd262c4cf28e.tar.gz |
Extend memory unit support in CONFIG SET.
Related to PR #2357.
-rw-r--r-- | src/config.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/config.c b/src/config.c index 927d7e245..3963a1218 100644 --- a/src/config.c +++ b/src/config.c @@ -624,6 +624,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]; @@ -643,7 +644,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; @@ -867,7 +867,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) { @@ -876,8 +875,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; } @@ -911,7 +910,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; |