]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Treat all errors in redis_pool as fatal errors for a connection
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 8 Sep 2016 13:40:38 +0000 (14:40 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 8 Sep 2016 13:40:38 +0000 (14:40 +0100)
src/libserver/redis_pool.c
src/lua/lua_redis.c

index e84f2360ea8d8c74a98e88ad0a59cfeff3d5389c..dd5adf2210f97b2d92c0838b209ff427a30a5a34 100644 (file)
@@ -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);
index 203def2d0dd9aa2e9214cf2abf150c58da44d1ca..4021903514076bdf096e53c66a701ea62330aaea 100644 (file)
@@ -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;