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
5d83e9e1
Commit
5d83e9e1
authored
May 17, 2020
by
Oran Agra
Browse files
improve DEBUG MALLCTL to be able to write to write only fields.
also support: debug mallctl-str thread.tcache.flush VOID
parent
23a85ba1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/debug.c
View file @
5d83e9e1
...
...
@@ -311,6 +311,13 @@ void mallctl_int(client *c, robj **argv, int argc) {
size_t
sz
=
sizeof
(
old
);
while
(
sz
>
0
)
{
if
((
ret
=
je_mallctl
(
argv
[
0
]
->
ptr
,
&
old
,
&
sz
,
argc
>
1
?
&
val
:
NULL
,
argc
>
1
?
sz
:
0
)))
{
if
(
ret
==
EPERM
&&
argc
>
1
)
{
/* if this option is write only, try just writing to it. */
if
(
!
(
ret
=
je_mallctl
(
argv
[
0
]
->
ptr
,
NULL
,
0
,
&
val
,
sz
)))
{
addReply
(
c
,
shared
.
ok
);
return
;
}
}
if
(
ret
==
EINVAL
)
{
/* size might be wrong, try a smaller one */
sz
/=
2
;
...
...
@@ -333,17 +340,30 @@ void mallctl_int(client *c, robj **argv, int argc) {
}
void
mallctl_string
(
client
*
c
,
robj
**
argv
,
int
argc
)
{
int
ret
;
int
rret
,
w
ret
;
char
*
old
;
size_t
sz
=
sizeof
(
old
);
/* for strings, it seems we need to first get the old value, before overriding it. */
if
((
ret
=
je_mallctl
(
argv
[
0
]
->
ptr
,
&
old
,
&
sz
,
NULL
,
0
)))
{
addReplyErrorFormat
(
c
,
"%s"
,
strerror
(
ret
));
return
;
if
((
rret
=
je_mallctl
(
argv
[
0
]
->
ptr
,
&
old
,
&
sz
,
NULL
,
0
)))
{
/* return error unless this option is write only. */
if
(
!
(
rret
==
EPERM
&&
argc
>
1
))
{
addReplyErrorFormat
(
c
,
"%s"
,
strerror
(
rret
));
return
;
}
}
if
(
argc
>
1
)
{
char
*
val
=
argv
[
1
]
->
ptr
;
char
**
valref
=
&
val
;
if
((
!
strcmp
(
val
,
"VOID"
)))
valref
=
NULL
,
sz
=
0
;
wret
=
je_mallctl
(
argv
[
0
]
->
ptr
,
NULL
,
0
,
valref
,
sz
);
}
addReplyBulkCString
(
c
,
old
);
if
(
argc
>
1
)
je_mallctl
(
argv
[
0
]
->
ptr
,
NULL
,
0
,
&
argv
[
1
]
->
ptr
,
sizeof
(
char
*
));
if
(
!
rret
)
addReplyBulkCString
(
c
,
old
);
else
if
(
wret
)
addReplyErrorFormat
(
c
,
"%s"
,
strerror
(
wret
));
else
addReply
(
c
,
shared
.
ok
);
}
#endif
...
...
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