summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-04-21 12:35:04 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-04-21 12:35:22 +0100
commit2ea40ec56af673b2aec231e7454a27e29fe39126 (patch)
treeb6f7fb60d12f559d1a643e9c9c8132d12d17a135
parente1c631ca5364f1694e1633f69edd867e62fc26c4 (diff)
downloadrspamd-2ea40ec56af673b2aec231e7454a27e29fe39126.tar.gz
rspamd-2ea40ec56af673b2aec231e7454a27e29fe39126.zip
[Minor] Improve logging for REDIS_REPLY_ERROR
-rw-r--r--src/libserver/fuzzy_backend/fuzzy_backend_redis.c20
-rw-r--r--src/libstat/backends/redis_backend.c22
-rw-r--r--src/libstat/learn_cache/redis_cache.c6
3 files changed, 42 insertions, 6 deletions
diff --git a/src/libserver/fuzzy_backend/fuzzy_backend_redis.c b/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
index d1e3e7532..f16040d8f 100644
--- a/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
+++ b/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
@@ -446,6 +446,10 @@ rspamd_fuzzy_redis_shingles_callback (redisAsyncContext *c, gpointer r,
}
}
}
+ else if (reply->type == REDIS_REPLY_ERROR) {
+ msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+ reply->str);
+ }
if (session->callback.cb_check) {
session->callback.cb_check (&rep, session->cbdata);
@@ -572,6 +576,10 @@ rspamd_fuzzy_redis_check_callback (redisAsyncContext *c, gpointer r,
}
}
}
+ else if (reply->type == REDIS_REPLY_ERROR) {
+ msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+ reply->str);
+ }
if (found_elts < 2) {
if (session->cmd->shingles_count > 0 && !session->shingles_checked) {
@@ -738,6 +746,10 @@ rspamd_fuzzy_redis_count_callback (redisAsyncContext *c, gpointer r,
}
}
else {
+ if (reply->type == REDIS_REPLY_ERROR) {
+ msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+ reply->str);
+ }
if (session->callback.cb_count) {
session->callback.cb_count (0, session->cbdata);
}
@@ -872,6 +884,10 @@ rspamd_fuzzy_redis_version_callback (redisAsyncContext *c, gpointer r,
}
}
else {
+ if (reply->type == REDIS_REPLY_ERROR) {
+ msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+ reply->str);
+ }
if (session->callback.cb_version) {
session->callback.cb_version (0, session->cbdata);
}
@@ -1373,6 +1389,10 @@ rspamd_fuzzy_redis_update_callback (redisAsyncContext *c, gpointer r,
}
}
else {
+ if (reply->type == REDIS_REPLY_ERROR) {
+ msg_err_redis_session ("fuzzy backend redis error: \"%s\"",
+ reply->str);
+ }
if (session->callback.cb_update) {
session->callback.cb_update (FALSE, 0, 0, 0, 0, session->cbdata);
}
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index 392f1704e..4136ab092 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -1212,8 +1212,14 @@ rspamd_redis_processed (redisAsyncContext *c, gpointer r, gpointer priv)
}
}
else {
- msg_err_task_check ("got invalid reply from redis: %s, array expected",
- rspamd_redis_type_to_string (reply->type));
+ if (reply->type == REDIS_REPLY_ERROR) {
+ msg_err_task_check ("cannot learn %s: redis error: \"%s\"",
+ rt->stcf->symbol, reply->str);
+ }
+ else {
+ msg_err_task_check ("got invalid reply from redis: %s, array expected",
+ rspamd_redis_type_to_string(reply->type));
+ }
}
msg_debug_stat_redis ("received tokens for %s: %d processed, %d found",
@@ -1264,9 +1270,15 @@ rspamd_redis_connected (redisAsyncContext *c, gpointer r, gpointer priv)
}
else {
if (reply->type != REDIS_REPLY_NIL) {
- msg_err_task ("bad learned type for %s: %s, nil expected",
- rt->stcf->symbol,
- rspamd_redis_type_to_string (reply->type));
+ if (reply->type == REDIS_REPLY_ERROR) {
+ msg_err_task ("cannot learn %s: redis error: \"%s\"",
+ rt->stcf->symbol, reply->str);
+ }
+ else {
+ msg_err_task ("bad learned type for %s: %s, nil expected",
+ rt->stcf->symbol,
+ rspamd_redis_type_to_string(reply->type));
+ }
}
val = 0;
diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index 73a72a614..570f3f6a2 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -141,7 +141,11 @@ rspamd_stat_cache_redis_get (redisAsyncContext *c, gpointer r, gpointer priv)
rspamd_strtol (reply->str, reply->len, &val);
}
else {
- if (reply->type != REDIS_REPLY_NIL) {
+ if (reply->type == REDIS_REPLY_ERROR) {
+ msg_err_task ("cannot learn %s: redis error: \"%s\"",
+ rt->ctx->stcf->symbol, reply->str);
+ }
+ else if (reply->type != REDIS_REPLY_NIL) {
msg_err_task ("bad learned type for %s: %d",
rt->ctx->stcf->symbol, reply->type);
}