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
3cf8dd2c
Commit
3cf8dd2c
authored
Jun 26, 2018
by
antirez
Browse files
Sentinel: fix SENTINEL SET error reporting.
Thanks to @shenlongxing for reporting the problem. Related to #5062.
parent
fc0c9c80
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
3cf8dd2c
...
@@ -3380,7 +3380,8 @@ void sentinelRoleCommand(client *c) {
...
@@ -3380,7 +3380,8 @@ void sentinelRoleCommand(client *c) {
void
sentinelSetCommand
(
client
*
c
)
{
void
sentinelSetCommand
(
client
*
c
)
{
sentinelRedisInstance
*
ri
;
sentinelRedisInstance
*
ri
;
int
j
,
changes
=
0
;
int
j
,
changes
=
0
;
char
*
option
,
*
value
;
int
badarg
=
0
;
/* Bad argument position for error reporting. */
char
*
option
;
if
((
ri
=
sentinelGetMasterByNameOrReplyError
(
c
,
c
->
argv
[
2
]))
if
((
ri
=
sentinelGetMasterByNameOrReplyError
(
c
,
c
->
argv
[
2
]))
==
NULL
)
return
;
==
NULL
)
return
;
...
@@ -3395,28 +3396,34 @@ void sentinelSetCommand(client *c) {
...
@@ -3395,28 +3396,34 @@ void sentinelSetCommand(client *c) {
if
(
!
strcasecmp
(
option
,
"down-after-milliseconds"
)
&&
moreargs
>
0
)
{
if
(
!
strcasecmp
(
option
,
"down-after-milliseconds"
)
&&
moreargs
>
0
)
{
/* down-after-millisecodns <milliseconds> */
/* down-after-millisecodns <milliseconds> */
robj
*
o
=
c
->
argv
[
++
j
];
robj
*
o
=
c
->
argv
[
++
j
];
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
C_ERR
||
ll
<=
0
)
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
C_ERR
||
ll
<=
0
)
{
badarg
=
j
;
goto
badfmt
;
goto
badfmt
;
}
ri
->
down_after_period
=
ll
;
ri
->
down_after_period
=
ll
;
sentinelPropagateDownAfterPeriod
(
ri
);
sentinelPropagateDownAfterPeriod
(
ri
);
changes
++
;
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"failover-timeout"
)
&&
moreargs
>
0
)
{
}
else
if
(
!
strcasecmp
(
option
,
"failover-timeout"
)
&&
moreargs
>
0
)
{
/* failover-timeout <milliseconds> */
/* failover-timeout <milliseconds> */
robj
*
o
=
c
->
argv
[
++
j
];
robj
*
o
=
c
->
argv
[
++
j
];
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
C_ERR
||
ll
<=
0
)
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
C_ERR
||
ll
<=
0
)
{
badarg
=
j
;
goto
badfmt
;
goto
badfmt
;
}
ri
->
failover_timeout
=
ll
;
ri
->
failover_timeout
=
ll
;
changes
++
;
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"parallel-syncs"
)
&&
moreargs
>
0
)
{
}
else
if
(
!
strcasecmp
(
option
,
"parallel-syncs"
)
&&
moreargs
>
0
)
{
/* parallel-syncs <milliseconds> */
/* parallel-syncs <milliseconds> */
robj
*
o
=
c
->
argv
[
++
j
];
robj
*
o
=
c
->
argv
[
++
j
];
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
C_ERR
||
ll
<=
0
)
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
C_ERR
||
ll
<=
0
)
{
badarg
=
j
;
goto
badfmt
;
goto
badfmt
;
}
ri
->
parallel_syncs
=
ll
;
ri
->
parallel_syncs
=
ll
;
changes
++
;
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"notification-script"
)
&&
moreargs
>
0
)
{
}
else
if
(
!
strcasecmp
(
option
,
"notification-script"
)
&&
moreargs
>
0
)
{
/* notification-script <path> */
/* notification-script <path> */
value
=
c
->
argv
[
++
j
]
->
ptr
;
char
*
value
=
c
->
argv
[
++
j
]
->
ptr
;
if
(
sentinel
.
deny_scripts_reconfig
)
{
if
(
sentinel
.
deny_scripts_reconfig
)
{
addReplyError
(
c
,
addReplyError
(
c
,
"Reconfiguration of scripts path is denied for "
"Reconfiguration of scripts path is denied for "
...
@@ -3436,7 +3443,7 @@ void sentinelSetCommand(client *c) {
...
@@ -3436,7 +3443,7 @@ void sentinelSetCommand(client *c) {
changes
++
;
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"client-reconfig-script"
)
&&
moreargs
>
0
)
{
}
else
if
(
!
strcasecmp
(
option
,
"client-reconfig-script"
)
&&
moreargs
>
0
)
{
/* client-reconfig-script <path> */
/* client-reconfig-script <path> */
value
=
c
->
argv
[
++
j
]
->
ptr
;
char
*
value
=
c
->
argv
[
++
j
]
->
ptr
;
if
(
sentinel
.
deny_scripts_reconfig
)
{
if
(
sentinel
.
deny_scripts_reconfig
)
{
addReplyError
(
c
,
addReplyError
(
c
,
"Reconfiguration of scripts path is denied for "
"Reconfiguration of scripts path is denied for "
...
@@ -3457,15 +3464,17 @@ void sentinelSetCommand(client *c) {
...
@@ -3457,15 +3464,17 @@ void sentinelSetCommand(client *c) {
changes
++
;
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"auth-pass"
)
&&
moreargs
>
0
)
{
}
else
if
(
!
strcasecmp
(
option
,
"auth-pass"
)
&&
moreargs
>
0
)
{
/* auth-pass <password> */
/* auth-pass <password> */
value
=
c
->
argv
[
++
j
]
->
ptr
;
char
*
value
=
c
->
argv
[
++
j
]
->
ptr
;
sdsfree
(
ri
->
auth_pass
);
sdsfree
(
ri
->
auth_pass
);
ri
->
auth_pass
=
strlen
(
value
)
?
sdsnew
(
value
)
:
NULL
;
ri
->
auth_pass
=
strlen
(
value
)
?
sdsnew
(
value
)
:
NULL
;
changes
++
;
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"quorum"
)
&&
moreargs
>
0
)
{
}
else
if
(
!
strcasecmp
(
option
,
"quorum"
)
&&
moreargs
>
0
)
{
/* quorum <count> */
/* quorum <count> */
robj
*
o
=
c
->
argv
[
++
j
];
robj
*
o
=
c
->
argv
[
++
j
];
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
C_ERR
||
ll
<=
0
)
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
C_ERR
||
ll
<=
0
)
{
badarg
=
j
;
goto
badfmt
;
goto
badfmt
;
}
ri
->
quorum
=
ll
;
ri
->
quorum
=
ll
;
changes
++
;
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"rename-command"
)
&&
moreargs
>
1
)
{
}
else
if
(
!
strcasecmp
(
option
,
"rename-command"
)
&&
moreargs
>
1
)
{
...
@@ -3516,7 +3525,7 @@ void sentinelSetCommand(client *c) {
...
@@ -3516,7 +3525,7 @@ void sentinelSetCommand(client *c) {
badfmt:
/* Bad format errors */
badfmt:
/* Bad format errors */
if
(
changes
)
sentinelFlushConfig
();
if
(
changes
)
sentinelFlushConfig
();
addReplyErrorFormat
(
c
,
"Invalid argument '%s' for SENTINEL SET '%s'"
,
addReplyErrorFormat
(
c
,
"Invalid argument '%s' for SENTINEL SET '%s'"
,
value
,
option
);
c
->
argv
[
badarg
]
->
ptr
,
option
);
}
}
/* Our fake PUBLISH command: it is actually useful only to receive hello messages
/* Our fake PUBLISH command: it is actually useful only to receive hello messages
...
...
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