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);
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) {
lua_pushboolean (L, FALSE);
lua_pushlstring (L, r->str, r->len);
}
+
freeReplyObject (r);
}
else {