]> source.dussan.org Git - rspamd.git/commitdiff
[CritFix] Add guards for inactive redis connections
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 20 Nov 2016 17:31:42 +0000 (17:31 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 20 Nov 2016 17:31:42 +0000 (17:31 +0000)
src/libserver/redis_pool.c

index 1efc4f7433f2488f11c22f8eb9426408e6b7f412..ef5951cfa8661245ae16a6824a374ce542951bdb 100644 (file)
@@ -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);