浏览代码

HPCC-15616 Redis plugin - UNWATCH WATCHed key in UNLOCK

Signed-off-by: James Noss <james.noss@lexisnexis.com>
James Noss 9 年之前
父节点
当前提交
e9283413bc
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      plugins/redis/redis.cpp

+ 7 - 1
plugins/redis/redis.cpp

@@ -1420,7 +1420,13 @@ void Connection::unlock(ICodeContext * ctx, const char * key)
         readReplyAndAssertWithCmdMsg(reply.get(), "manual unlock", key);//DEL reply
         readReplyAndAssertWithCmdMsg(reply.get(), "manual unlock", key);//EXEC reply
     }
-    //If the above is aborted, let the lock expire.
+    else
+    {
+        reply->setClear(redisCommand("UNWATCH"));
+        //Close connection upon failing to UNWATCH.
+        if (!reply->query() || (reply->query()->type != REDIS_REPLY_STATUS) || (strcmp(reply->query()->str, "OK") != 0))
+            freeContext();
+    }
 }
 void Connection::handleLockOnGet(ICodeContext * ctx, const char * key, MemoryAttr * retVal, const char * password, unsigned expire)
 {