Browse Source

Use xxh64 for upstreams hashing.

tags/0.9.0
Vsevolod Stakhov 9 years ago
parent
commit
a022d264bb
1 changed files with 3 additions and 8 deletions
  1. 3
    8
      src/libutil/upstream.c

+ 3
- 8
src/libutil/upstream.c View File

@@ -634,19 +634,14 @@ rspamd_consistent_hash (guint64 key, guint32 nbuckets)
static struct upstream*
rspamd_upstream_get_hashed (struct upstream_list *ups, const guint8 *key, guint keylen)
{
union {
guint64 k64;
guint32 k32[2];
} h;

guint64 k;
guint32 idx;

/* Generate 64 bits input key */
h.k32[0] = XXH32 (key, keylen, ((guint32*)&ups->hash_seed)[0]);
h.k32[1] = XXH32 (key, keylen, ((guint32*)&ups->hash_seed)[1]);
k = XXH64 (key, keylen, ups->hash_seed);

rspamd_mutex_lock (ups->lock);
idx = rspamd_consistent_hash (h.k64, ups->alive->len);
idx = rspamd_consistent_hash (k, ups->alive->len);
rspamd_mutex_unlock (ups->lock);

return g_ptr_array_index (ups->alive, idx);

Loading…
Cancel
Save