]> git.saurik.com Git - redis.git/commitdiff
Fix EXEC bug that was leaving the client in dirty status when used with WATCH
authorantirez <antirez@gmail.com>
Wed, 26 May 2010 15:50:29 +0000 (17:50 +0200)
committerantirez <antirez@gmail.com>
Wed, 26 May 2010 15:50:29 +0000 (17:50 +0200)
redis.c

diff --git a/redis.c b/redis.c
index f18eabe6afed27095f070f972cf614be8e1f836d..def0e6b8bc3db5e1e1a1f43347624b657961b2d8 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -7556,6 +7556,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));
@@ -7568,8 +7569,7 @@ static void execCommand(redisClient *c) {
     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). */