diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-09-16 13:38:35 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-09-16 13:38:35 +0100 |
commit | c2cdf7ceb0b590645f992a62bbab4382a0319617 (patch) | |
tree | 22412333f17ce11533fc9e0cc828fd78d4d5e3ae /src | |
parent | 7a1db4723f50b0d9cdaab52aa84851c54f5ff3c2 (diff) | |
download | rspamd-c2cdf7ceb0b590645f992a62bbab4382a0319617.tar.gz rspamd-c2cdf7ceb0b590645f992a62bbab4382a0319617.zip |
[Minor] Fix unregistration of the context and improve logging
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/redis_pool.cxx | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/libserver/redis_pool.cxx b/src/libserver/redis_pool.cxx index 8cdb12587..e2deb5181 100644 --- a/src/libserver/redis_pool.cxx +++ b/src/libserver/redis_pool.cxx @@ -261,32 +261,35 @@ redis_pool_connection::~redis_pool_connection() const auto *conn = this; /* For debug */ if (state == RSPAMD_REDIS_POOL_CONN_ACTIVE) { - msg_debug_rpool ("active connection destructed"); + msg_debug_rpool ("active connection destructed: %p", ctx); if (ctx) { + pool->unregister_context(ctx); + if (!(ctx->c.flags & REDIS_FREEING)) { auto *ac = ctx; ctx = nullptr; - pool->unregister_context(ac); ac->onDisconnect = nullptr; redisAsyncFree(ac); } } } else { - msg_debug_rpool("inactive connection destructed"); + msg_debug_rpool("inactive connection destructed: %p", ctx); ev_timer_stop(pool->event_loop, &timeout); + if (ctx) { + pool->unregister_context(ctx); - if (ctx && !(ctx->c.flags & REDIS_FREEING)) { - redisAsyncContext *ac = ctx; + if (!(ctx->c.flags & REDIS_FREEING)) { + redisAsyncContext *ac = ctx; - /* To prevent on_disconnect here */ - state = RSPAMD_REDIS_POOL_CONN_FINALISING; - pool->unregister_context(ac); - ctx = nullptr; - ac->onDisconnect = nullptr; - redisAsyncFree(ac); + /* To prevent on_disconnect here */ + state = RSPAMD_REDIS_POOL_CONN_FINALISING; + ctx = nullptr; + ac->onDisconnect = nullptr; + redisAsyncFree(ac); + } } } } |