diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-25 14:52:37 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-25 14:52:37 +0000 |
commit | de8ca5b3ac969491416a064840f963622fd3d59c (patch) | |
tree | bb18db8d4ee8892257ebc5e9bd1c62eb6ccf2479 | |
parent | 8b24e979107b29276c0d306296475d2c5feb88e8 (diff) | |
download | rspamd-de8ca5b3ac969491416a064840f963622fd3d59c.tar.gz rspamd-de8ca5b3ac969491416a064840f963622fd3d59c.zip |
[Fix] Try to fix race condition in redis_pool
-rw-r--r-- | src/libserver/redis_pool.c | 10 | ||||
-rw-r--r-- | src/libutil/shingles.c | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/libserver/redis_pool.c b/src/libserver/redis_pool.c index 578115571..1d42ad3ff 100644 --- a/src/libserver/redis_pool.c +++ b/src/libserver/redis_pool.c @@ -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); diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c index 4f2e85fa1..b2990de63 100644 --- a/src/libutil/shingles.c +++ b/src/libutil/shingles.c @@ -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, |