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
8897c154
Commit
8897c154
authored
Mar 18, 2019
by
Yossi Gottlieb
Committed by
antirez
May 13, 2019
Browse files
CommandFilter API: Support Lua and RM_call() flows.
parent
6dd5bad4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
8897c154
...
...
@@ -2740,12 +2740,6 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch
RedisModuleCallReply
*
reply
=
NULL
;
int
replicate
=
0
;
/* Replicate this command? */
cmd
=
lookupCommandByCString
((
char
*
)
cmdname
);
if
(
!
cmd
)
{
errno
=
EINVAL
;
return
NULL
;
}
/* Create the client and dispatch the command. */
va_start
(
ap
,
fmt
);
c
=
createClient
(
-
1
);
...
...
@@ -2758,11 +2752,23 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch
c
->
db
=
ctx
->
client
->
db
;
c
->
argv
=
argv
;
c
->
argc
=
argc
;
c
->
cmd
=
c
->
lastcmd
=
cmd
;
/* We handle the above format error only when the client is setup so that
* we can free it normally. */
if
(
argv
==
NULL
)
goto
cleanup
;
/* Call command filters */
moduleCallCommandFilters
(
c
);
/* Lookup command now, after filters had a chance to make modifications
* if necessary.
*/
cmd
=
lookupCommand
(
c
->
argv
[
0
]
->
ptr
);
if
(
!
cmd
)
{
errno
=
EINVAL
;
goto
cleanup
;
}
c
->
cmd
=
c
->
lastcmd
=
cmd
;
/* Basic arity checks. */
if
((
cmd
->
arity
>
0
&&
cmd
->
arity
!=
argc
)
||
(
argc
<
-
cmd
->
arity
))
{
errno
=
EINVAL
;
...
...
src/scripting.c
View file @
8897c154
...
...
@@ -443,6 +443,11 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
c
->
argv
=
argv
;
c
->
argc
=
argc
;
/* Process module hooks */
moduleCallCommandFilters
(
c
);
argv
=
c
->
argv
;
argc
=
c
->
argc
;
/* Log the command if debugging is active. */
if
(
ldb
.
active
&&
ldb
.
step
)
{
sds
cmdlog
=
sdsnew
(
"<redis>"
);
...
...
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