aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/learn_cache/redis_cache.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-22 16:14:13 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-22 16:14:13 +0100
commitff1f29cc7270742b8c1a24b8c72e4f3e9ba2b820 (patch)
tree117ae95e0b3ab76c62927b082940690728686208 /src/libstat/learn_cache/redis_cache.c
parent7c0ded82ed4f4d179226e16912b8529d82f5d9a8 (diff)
downloadrspamd-ff1f29cc7270742b8c1a24b8c72e4f3e9ba2b820.tar.gz
rspamd-ff1f29cc7270742b8c1a24b8c72e4f3e9ba2b820.zip
[Fix] Important hiredis fixes
Hiredis can return error in two ways: - ctx is NULL and this path is usually handled properly - ctx->err is not REDIS_OK and this path is totally missing in many places This change should fix the both cases.
Diffstat (limited to 'src/libstat/learn_cache/redis_cache.c')
-rw-r--r--src/libstat/learn_cache/redis_cache.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index 82c354bb6..a76ad585c 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -396,7 +396,22 @@ rspamd_stat_cache_redis_runtime (struct rspamd_task *task,
rspamd_inet_address_get_port (addr));
}
- g_assert (rt->redis != NULL);
+ if (rt->redis == NULL) {
+ msg_warn_task ("cannot connect to redis server %s: %s",
+ rspamd_inet_address_to_string_pretty (addr),
+ strerror (errno));
+
+ return NULL;
+ }
+ else if (rt->redis->err != REDIS_OK) {
+ msg_warn_task ("cannot connect to redis server %s: %s",
+ rspamd_inet_address_to_string_pretty (addr),
+ rt->redis->errstr);
+ redisAsyncFree (rt->redis);
+ rt->redis = NULL;
+
+ return NULL;
+ }
redisLibevAttach (task->event_loop, rt->redis);