提交 6531c94d 编写于 作者: A antirez

raise error on nested MULTI and WATCH inside multi

上级 bc000c1d
...@@ -2446,7 +2446,10 @@ static int processCommand(redisClient *c) { ...@@ -2446,7 +2446,10 @@ static int processCommand(redisClient *c) {
} }
/* Exec the command */ /* Exec the command */
if (c->flags & REDIS_MULTI && cmd->proc != execCommand && cmd->proc != discardCommand) { if (c->flags & REDIS_MULTI &&
cmd->proc != execCommand && cmd->proc != discardCommand &&
cmd->proc != multiCommand && cmd->proc != watchCommand)
{
queueMultiCommand(c,cmd); queueMultiCommand(c,cmd);
addReply(c,shared.queued); addReply(c,shared.queued);
} else { } else {
...@@ -7498,6 +7501,10 @@ static void queueMultiCommand(redisClient *c, struct redisCommand *cmd) { ...@@ -7498,6 +7501,10 @@ static void queueMultiCommand(redisClient *c, struct redisCommand *cmd) {
} }
static void multiCommand(redisClient *c) { static void multiCommand(redisClient *c) {
if (c->flags & REDIS_MULTI) {
addReplySds(c,sdsnew("-ERR MULTI calls can not be nested\r\n"));
return;
}
c->flags |= REDIS_MULTI; c->flags |= REDIS_MULTI;
addReply(c,shared.ok); addReply(c,shared.ok);
} }
...@@ -10513,6 +10520,10 @@ static void touchWatchedKeysOnFlush(int dbid) { ...@@ -10513,6 +10520,10 @@ static void touchWatchedKeysOnFlush(int dbid) {
static void watchCommand(redisClient *c) { static void watchCommand(redisClient *c) {
int j; int j;
if (c->flags & REDIS_MULTI) {
addReplySds(c,sdsnew("-ERR WATCH inside MULTI is not allowed\r\n"));
return;
}
for (j = 1; j < c->argc; j++) for (j = 1; j < c->argc; j++)
watchForKey(c,c->argv[j]); watchForKey(c,c->argv[j]);
addReply(c,shared.ok); addReply(c,shared.ok);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册