From 3ef18da334f2022040a6529c1cbc2f311567480f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 21 Feb 2018 15:44:56 +0000 Subject: [Fix] Fix reusing of redis connection after exec --- src/lua/lua_redis.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/lua/lua_redis.c') diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index 7688d8cfd..557639cef 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -1278,7 +1278,7 @@ lua_redis_exec (lua_State *L) struct lua_redis_ctx *ctx = lua_check_redis (L, 1); redisReply *r; gint ret; - guint i, nret = 0; + guint i, nret = 0, pending; if (ctx == NULL) { lua_error (L); @@ -1302,7 +1302,11 @@ lua_redis_exec (lua_State *L) return luaL_error (L, "cannot resiz stack to fit %d commands", ctx->cmds_pending); } - for (i = 0; i < ctx->cmds_pending; i ++) { + + pending = ctx->cmds_pending; + ctx->cmds_pending = 0; + + for (i = 0; i < pending; i ++) { ret = redisGetReply (ctx->d.sync, (void **)&r); if (ret == REDIS_OK) { @@ -1315,6 +1319,7 @@ lua_redis_exec (lua_State *L) lua_pushboolean (L, FALSE); lua_pushlstring (L, r->str, r->len); } + freeReplyObject (r); } else { -- cgit v1.2.3