]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Try to fix race condition in redis_pool
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 25 Dec 2016 14:52:37 +0000 (14:52 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 25 Dec 2016 14:52:37 +0000 (14:52 +0000)
src/libserver/redis_pool.c
src/libutil/shingles.c

index 578115571edbd6f9a5fab59a0a7b91d814d3bfdd..1d42ad3ff90edbf1b0b83aee9b505c66c58da6db 100644 (file)
@@ -102,8 +102,14 @@ rspamd_redis_pool_conn_dtor (struct rspamd_redis_pool_connection *conn)
                msg_debug_rpool ("active connection removed");
 
                if (conn->ctx) {
-                       g_hash_table_remove (conn->elt->pool->elts_by_ctx, conn->ctx);
-                       redisAsyncFree (conn->ctx);
+                       if (!(conn->ctx->c.flags & REDIS_FREEING)) {
+                               redisAsyncContext *ac = conn->ctx;
+
+                               conn->ctx = NULL;
+                               g_hash_table_remove (conn->elt->pool->elts_by_ctx, conn->ctx);
+                               ac->onDisconnect = NULL;
+                               redisAsyncFree (ac);
+                       }
                }
 
                g_queue_unlink (conn->elt->active, conn->entry);
index 4f2e85fa197c68efa7c76b69c30353723057490c..b2990de63ca0e872d316d8e422a213f5438f4bd2 100644 (file)
@@ -115,7 +115,6 @@ rspamd_shingles_from_text (GArray *input,
                }
 
                memset (res, 0, sizeof (res));
-
                for (i = 0; i <= (gint)input->len; i ++) {
                        if (i - beg >= SHINGLES_WINDOW || i == (gint)input->len) {
 
@@ -248,7 +247,7 @@ rspamd_shingles_from_image (guchar *dct,
 
                beg++;
        }
-
+#undef INNER_CYCLE_SHINGLES
        /* Now we need to filter all hashes and make a shingles result */
        for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
                shingle->hashes[i] = filter (hashes[i], hlen,