diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-21 15:44:56 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-21 15:44:56 +0000 |
commit | 3ef18da334f2022040a6529c1cbc2f311567480f (patch) | |
tree | 72e5e4e75e28b3f8abb2ed40e3045d0d2dc5e882 /src/lua/lua_redis.c | |
parent | 7433897aef2713a4bc5e60022ae0775051fa7409 (diff) | |
download | rspamd-3ef18da334f2022040a6529c1cbc2f311567480f.tar.gz rspamd-3ef18da334f2022040a6529c1cbc2f311567480f.zip |
[Fix] Fix reusing of redis connection after exec
Diffstat (limited to 'src/lua/lua_redis.c')
-rw-r--r-- | src/lua/lua_redis.c | 9 |
1 files changed, 7 insertions, 2 deletions
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 { |