Browse Source

[Fix] Try to fix race condition in redis_pool

tags/1.5.0
Vsevolod Stakhov 7 years ago
parent
commit
de8ca5b3ac
2 changed files with 9 additions and 4 deletions
  1. 8
    2
      src/libserver/redis_pool.c
  2. 1
    2
      src/libutil/shingles.c

+ 8
- 2
src/libserver/redis_pool.c View File

msg_debug_rpool ("active connection removed"); msg_debug_rpool ("active connection removed");


if (conn->ctx) { 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); g_queue_unlink (conn->elt->active, conn->entry);

+ 1
- 2
src/libutil/shingles.c View File

} }


memset (res, 0, sizeof (res)); memset (res, 0, sizeof (res));

for (i = 0; i <= (gint)input->len; i ++) { for (i = 0; i <= (gint)input->len; i ++) {
if (i - beg >= SHINGLES_WINDOW || i == (gint)input->len) { if (i - beg >= SHINGLES_WINDOW || i == (gint)input->len) {




beg++; beg++;
} }
#undef INNER_CYCLE_SHINGLES
/* Now we need to filter all hashes and make a shingles result */ /* Now we need to filter all hashes and make a shingles result */
for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) { for (i = 0; i < RSPAMD_SHINGLE_SIZE; i ++) {
shingle->hashes[i] = filter (hashes[i], hlen, shingle->hashes[i] = filter (hashes[i], hlen,

Loading…
Cancel
Save