defrag: link hash size with number of frags.

We set defrag_hash_size by using the number of trackers. This is
effective to avoid collision.
pull/27/head
Eric Leblond 13 years ago
parent f328e18d59
commit 0fd2c93c96

@ -418,7 +418,7 @@ DefragContextNew(void)
return NULL;
/* Initialize the hash table. */
dc->frag_table = HashListTableInit(DEFAULT_DEFRAG_HASH_SIZE, DefragHashFunc,
dc->frag_table = HashListTableInit(defrag_hash_size, DefragHashFunc,
DefragHashCompare, DefragHashFree);
if (dc->frag_table == NULL) {
SCLogError(SC_ERR_MEM_ALLOC,
@ -1238,10 +1238,14 @@ DefragInit(void)
{
/* Initialize random value for hashing and hash table size. */
unsigned int seed = RandomTimePreseed();
/* set defaults */
defrag_hash_rand = (int)( DEFAULT_DEFRAG_HASH_SIZE * (rand_r(&seed) / RAND_MAX + 1.0));
intmax_t tracker_pool_size;
if (!ConfGetInt("defrag.trackers", &tracker_pool_size)) {
tracker_pool_size = DEFAULT_DEFRAG_HASH_SIZE;
}
defrag_hash_size = DEFAULT_DEFRAG_HASH_SIZE;
/* set defaults */
defrag_hash_rand = (int)(tracker_pool_size * (rand_r(&seed) / RAND_MAX + 1.0));
defrag_hash_size = tracker_pool_size;
/* Allocate the DefragContext. */
defrag_context = DefragContextNew();

Loading…
Cancel
Save