Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
cd4e0f43
Commit
cd4e0f43
authored
Feb 12, 2015
by
antirez
Browse files
Extend memory unit support in CONFIG SET.
Related to PR #2357.
parent
866b3fc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/config.c
View file @
cd4e0f43
...
@@ -624,6 +624,7 @@ void loadServerConfig(char *filename, char *options) {
...
@@ -624,6 +624,7 @@ void loadServerConfig(char *filename, char *options) {
void
configSetCommand
(
redisClient
*
c
)
{
void
configSetCommand
(
redisClient
*
c
)
{
robj
*
o
;
robj
*
o
;
long
long
ll
;
long
long
ll
;
int
err
;
redisAssertWithInfo
(
c
,
c
->
argv
[
2
],
sdsEncodedObject
(
c
->
argv
[
2
]));
redisAssertWithInfo
(
c
,
c
->
argv
[
2
],
sdsEncodedObject
(
c
->
argv
[
2
]));
redisAssertWithInfo
(
c
,
c
->
argv
[
3
],
sdsEncodedObject
(
c
->
argv
[
3
]));
redisAssertWithInfo
(
c
,
c
->
argv
[
3
],
sdsEncodedObject
(
c
->
argv
[
3
]));
o
=
c
->
argv
[
3
];
o
=
c
->
argv
[
3
];
...
@@ -643,7 +644,6 @@ void configSetCommand(redisClient *c) {
...
@@ -643,7 +644,6 @@ void configSetCommand(redisClient *c) {
zfree
(
server
.
masterauth
);
zfree
(
server
.
masterauth
);
server
.
masterauth
=
((
char
*
)
o
->
ptr
)[
0
]
?
zstrdup
(
o
->
ptr
)
:
NULL
;
server
.
masterauth
=
((
char
*
)
o
->
ptr
)[
0
]
?
zstrdup
(
o
->
ptr
)
:
NULL
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"maxmemory"
))
{
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"maxmemory"
))
{
int
err
;
ll
=
memtoll
(
o
->
ptr
,
&
err
);
ll
=
memtoll
(
o
->
ptr
,
&
err
);
if
(
err
||
ll
<
0
)
goto
badfmt
;
if
(
err
||
ll
<
0
)
goto
badfmt
;
server
.
maxmemory
=
ll
;
server
.
maxmemory
=
ll
;
...
@@ -867,7 +867,6 @@ void configSetCommand(redisClient *c) {
...
@@ -867,7 +867,6 @@ void configSetCommand(redisClient *c) {
* whole configuration string or accept it all, even if a single
* whole configuration string or accept it all, even if a single
* error in a single client class is present. */
* error in a single client class is present. */
for
(
j
=
0
;
j
<
vlen
;
j
++
)
{
for
(
j
=
0
;
j
<
vlen
;
j
++
)
{
char
*
eptr
;
long
val
;
long
val
;
if
((
j
%
4
)
==
0
)
{
if
((
j
%
4
)
==
0
)
{
...
@@ -876,8 +875,8 @@ void configSetCommand(redisClient *c) {
...
@@ -876,8 +875,8 @@ void configSetCommand(redisClient *c) {
goto
badfmt
;
goto
badfmt
;
}
}
}
else
{
}
else
{
val
=
str
toll
(
v
[
j
],
&
e
ptr
,
10
);
val
=
mem
toll
(
v
[
j
],
&
e
rr
);
if
(
e
ptr
[
0
]
!=
'\0'
||
val
<
0
)
{
if
(
e
rr
||
val
<
0
)
{
sdsfreesplitres
(
v
,
vlen
);
sdsfreesplitres
(
v
,
vlen
);
goto
badfmt
;
goto
badfmt
;
}
}
...
@@ -911,7 +910,8 @@ void configSetCommand(redisClient *c) {
...
@@ -911,7 +910,8 @@ void configSetCommand(redisClient *c) {
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<=
0
)
goto
badfmt
;
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<=
0
)
goto
badfmt
;
server
.
repl_timeout
=
ll
;
server
.
repl_timeout
=
ll
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"repl-backlog-size"
))
{
}
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
);
resizeReplicationBacklog
(
ll
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"repl-backlog-ttl"
))
{
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"repl-backlog-ttl"
))
{
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
)
goto
badfmt
;
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<
0
)
goto
badfmt
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment