aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-23 14:02:34 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-23 14:02:34 +0100
commit7721a1a19baa139b460ec6126987a4943b4facb6 (patch)
treeeff16a6e21bd5d6253126fbc0ee914e5652e07ca /src
parentfbcad3a82764ea352d27a3f80183fbcc18afc199 (diff)
downloadrspamd-7721a1a19baa139b460ec6126987a4943b4facb6.tar.gz
rspamd-7721a1a19baa139b460ec6126987a4943b4facb6.zip
[Minor] Ensure that Redis inactive connections are well maintained
Diffstat (limited to 'src')
-rw-r--r--src/libserver/redis_pool.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libserver/redis_pool.cxx b/src/libserver/redis_pool.cxx
index 3d56623c8..052f2eb7c 100644
--- a/src/libserver/redis_pool.cxx
+++ b/src/libserver/redis_pool.cxx
@@ -386,6 +386,9 @@ redis_pool_connection::schedule_timeout() -> void
ctx, real_timeout);
timeout.data = this;
+ /* Restore in case if these fields have been modified externally */
+ ctx->data = this;
+ redisAsyncSetDisconnectCallback(ctx, redis_pool_connection::redis_on_disconnect);
ev_timer_init(&timeout,
redis_pool_connection::redis_conn_timeout_cb,
real_timeout, real_timeout / 2.0);
@@ -527,7 +530,7 @@ auto redis_pool::release_connection(redisAsyncContext *ctx,
else {
if (how == RSPAMD_REDIS_RELEASE_DEFAULT) {
/* Ensure that there are no callbacks attached to this conn */
- if (ctx->replies.head == nullptr) {
+ if (ctx->replies.head == nullptr && (ctx->c.flags & REDIS_CONNECTED)) {
/* Just move it to the inactive queue */
conn->state = rspamd_redis_pool_connection_state::RSPAMD_REDIS_POOL_CONN_INACTIVE;
conn->elt->move_to_inactive(conn);