From: Vsevolod Stakhov Date: Sun, 20 Nov 2016 17:31:42 +0000 (+0000) Subject: [CritFix] Add guards for inactive redis connections X-Git-Tag: 1.4.0~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0a236ecb96a47a3a08e45f0a5562aeb39f4256ea;p=rspamd.git [CritFix] Add guards for inactive redis connections --- diff --git a/src/libserver/redis_pool.c b/src/libserver/redis_pool.c index 1efc4f743..ef5951cfa 100644 --- a/src/libserver/redis_pool.c +++ b/src/libserver/redis_pool.c @@ -115,11 +115,15 @@ rspamd_redis_pool_conn_dtor (struct rspamd_redis_pool_connection *conn) event_del (&conn->timeout); } - if (conn->ctx) { + if (conn->ctx && !(conn->ctx->c->flags & REDIS_FREEING)) { + redisAsyncContext *ac = conn->ctx; + /* To prevent on_disconnect here */ conn->active = TRUE; g_hash_table_remove (conn->elt->pool->elts_by_ctx, conn->ctx); - redisAsyncFree (conn->ctx); + conn->ctx = NULL; + ac->onDisconnect = NULL; + redisAsyncFree (ac); } g_queue_unlink (conn->elt->inactive, conn->entry);