From: Vsevolod Stakhov Date: Thu, 8 Sep 2016 13:40:38 +0000 (+0100) Subject: [Fix] Treat all errors in redis_pool as fatal errors for a connection X-Git-Tag: 1.4.0~467 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2996fbba0a369032f96c0d6689ae2b6b623065d4;p=thirdparty%2Frspamd.git [Fix] Treat all errors in redis_pool as fatal errors for a connection --- diff --git a/src/libserver/redis_pool.c b/src/libserver/redis_pool.c index e84f2360ea..dd5adf2210 100644 --- a/src/libserver/redis_pool.c +++ b/src/libserver/redis_pool.c @@ -334,7 +334,7 @@ rspamd_redis_pool_release_connection (struct rspamd_redis_pool *pool, if (conn != NULL) { g_assert (conn->active); - if (is_fatal || ctx->err == REDIS_ERR_IO || ctx->err == REDIS_ERR_EOF) { + if (is_fatal || ctx->err != REDIS_OK) { /* We need to terminate connection forcefully */ msg_debug_rpool ("closed connection forcefully"); REF_RELEASE (conn); diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index 203def2d0d..4021903514 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -661,6 +661,8 @@ lua_redis_make_request (lua_State *L) if (ud->ctx) { msg_err_task_check ("cannot connect to redis: %s", ud->ctx->errstr); + rspamd_redis_pool_release_connection (task->cfg->redis_pool, + ud->ctx, TRUE); ud->ctx = NULL; } else { @@ -701,7 +703,7 @@ lua_redis_make_request (lua_State *L) else { msg_info_task_check ("call to redis failed: %s", ud->ctx->errstr); rspamd_redis_pool_release_connection (task->cfg->redis_pool, - ud->ctx, FALSE); + ud->ctx, TRUE); ud->ctx = NULL; REDIS_RELEASE (ctx); ret = FALSE;