From: antirez Date: Wed, 26 May 2010 15:55:28 +0000 (+0200) Subject: Merge branch 'master' into nested-multi X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/90fdc82697823a4e8228ae7e5c5ada0f56d160d7?hp=-c Merge branch 'master' into nested-multi --- 90fdc82697823a4e8228ae7e5c5ada0f56d160d7 diff --combined redis.c index da5baa2e,def0e6b8..2d509995 --- a/redis.c +++ b/redis.c @@@ -2446,10 -2446,7 +2446,10 @@@ static int processCommand(redisClient * } /* 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); addReply(c,shared.queued); } else { @@@ -7501,10 -7498,6 +7501,10 @@@ static void queueMultiCommand(redisClie } 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; addReply(c,shared.ok); } @@@ -7563,6 -7556,7 +7563,7 @@@ static void execCommand(redisClient *c execCommandReplicateMulti(c); /* Exec all the queued commands */ + unwatchAllKeys(c); /* Unwatch ASAP otherwise we'll waste CPU cycles */ orig_argv = c->argv; orig_argc = c->argc; addReplySds(c,sdscatprintf(sdsempty(),"*%d\r\n",c->mstate.count)); @@@ -7575,8 -7569,7 +7576,7 @@@ c->argc = orig_argc; freeClientMultiState(c); initClientMultiState(c); - c->flags &= (~REDIS_MULTI); - unwatchAllKeys(c); + c->flags &= ~(REDIS_MULTI|REDIS_DIRTY_CAS); /* Make sure the EXEC command is always replicated / AOF, since we * always send the MULTI command (we can't know beforehand if the * next operations will contain at least a modification to the DB). */ @@@ -10520,10 -10513,6 +10520,10 @@@ static void touchWatchedKeysOnFlush(in static void watchCommand(redisClient *c) { 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++) watchForKey(c,c->argv[j]); addReply(c,shared.ok);