summaryrefslogtreecommitdiff
path: root/src/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/module.c')
-rw-r--r--src/module.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/module.c b/src/module.c
index c6cb8a0ca..17accfb70 100644
--- a/src/module.c
+++ b/src/module.c
@@ -2741,12 +2741,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);
@@ -2760,11 +2754,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;