Skip to content

Commit

Permalink
Problem: [zhashx] rehash does not increase chain limit
Browse files Browse the repository at this point in the history
When rehashing in s_item_lookup(), the chain limit was not increased.
Therefore, the chain limit stayed at its default value of 1.  By staying
at the default value of 1, a single hash collision could increase the
limit of the hash.  This increase could be well beyond what would be
reasonable.

Solution: Increase the chain limit by the growth factor after a rehash.

Fixes zeromq#2173
  • Loading branch information
chu11 committed Apr 10, 2021
1 parent 4364943 commit 9009cd8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/zhashx.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ s_item_lookup (zhashx_t *self, const void *key)
assert (s_zhashx_rehash (self, new_prime_index) == 0);
limit = primes [self->prime_index];
self->cached_index = self->hasher (key) % limit;
self->chain_limit += CHAIN_GROWS;
}
return item;
}
Expand Down

0 comments on commit 9009cd8

Please sign in to comment.