diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-30 12:53:20 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-30 12:53:20 +0100 |
commit | 81a01f43d3c1de562273b30025b018d38a5aadf6 (patch) | |
tree | 72e15a7c399320f8309f6e78fa60b27a97322e3d /src/lua/lua_redis.c | |
parent | 03165efaa67359fdcabb6206ed02cba36498be5a (diff) | |
download | rspamd-81a01f43d3c1de562273b30025b018d38a5aadf6.tar.gz rspamd-81a01f43d3c1de562273b30025b018d38a5aadf6.zip |
[Minor] Try to deal with errors in lua_redis
Diffstat (limited to 'src/lua/lua_redis.c')
-rw-r--r-- | src/lua/lua_redis.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index 455afd9b6..a115708e3 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -152,7 +152,7 @@ lua_redis_dtor (struct lua_redis_ctx *ctx) { struct lua_redis_userdata *ud; struct lua_redis_specific_userdata *cur, *tmp; - gboolean is_connected = FALSE; + gboolean is_connected = FALSE, is_successfull = TRUE; struct redisAsyncContext *ac; if (ctx->async) { @@ -160,6 +160,17 @@ lua_redis_dtor (struct lua_redis_ctx *ctx) ud = &ctx->d.async; if (ud->ctx) { + + LL_FOREACH_SAFE (ud->specific, cur, tmp) { + if (is_connected) { + event_del (&cur->timeout); + } + + if (!cur->replied) { + is_successfull = FALSE; + } + } + ud->terminated = 1; /* * On calling of redisFree, hiredis calls for callbacks pending @@ -170,17 +181,14 @@ lua_redis_dtor (struct lua_redis_ctx *ctx) ac = ud->ctx; ud->ctx = NULL; rspamd_redis_pool_release_connection (ud->task->cfg->redis_pool, - ac, FALSE); + ac, is_successfull); ctx->ref.refcount = 0; is_connected = TRUE; } + LL_FOREACH_SAFE (ud->specific, cur, tmp) { lua_redis_free_args (cur->args, cur->nargs); - if (is_connected) { - event_del (&cur->timeout); - } - if (cur->cbref != -1) { luaL_unref (ud->L, LUA_REGISTRYINDEX, cur->cbref); } @@ -218,7 +226,6 @@ lua_redis_fin (void *arg) ctx = sp_ud->ctx; event_del (&sp_ud->timeout); msg_debug ("finished redis query %p from session %p", sp_ud, ctx); - sp_ud->replied = TRUE; sp_ud->c->terminated = TRUE; REDIS_RELEASE (ctx); @@ -326,6 +333,7 @@ lua_redis_push_data (const redisReply *r, struct lua_redis_ctx *ctx, } + sp_ud->replied = TRUE; rspamd_session_watcher_pop (ud->task->s, sp_ud->w); rspamd_session_remove_event (ud->task->s, lua_redis_fin, sp_ud); } |