aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/hash.c11
-rw-r--r--src/hash.h2
-rw-r--r--src/main.c2
-rw-r--r--src/statfile.c2
4 files changed, 9 insertions, 8 deletions
diff --git a/src/hash.c b/src/hash.c
index a8309ff36..ab9830d2d 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -179,12 +179,12 @@ rspamd_hash_new (memory_pool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_
* Create new hash in specified pool using shared memory
*/
rspamd_hash_t*
-rspamd_hash_new_shared (memory_pool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_func)
+rspamd_hash_new_shared (memory_pool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_func, gint size)
{
rspamd_hash_t* hash;
hash = memory_pool_alloc_shared (pool, sizeof (rspamd_hash_t));
- hash->size = HASH_TABLE_MIN_SIZE;
+ hash->size = size;
hash->nnodes = 0;
hash->hash_func = hash_func ? hash_func : g_direct_hash;
hash->key_equal_func = key_equal_func;
@@ -235,9 +235,10 @@ rspamd_hash_insert (rspamd_hash_t *hash, gpointer key, gpointer value)
if (hash->shared) {
memory_pool_wunlock_rwlock (hash->lock);
}
-
- rspamd_hash_maybe_resize (hash);
-
+
+ if (!hash->shared) {
+ rspamd_hash_maybe_resize (hash);
+ }
}
/*
diff --git a/src/hash.h b/src/hash.h
index 024cb3851..594b6c63b 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -46,7 +46,7 @@ rspamd_hash_t* rspamd_hash_new (memory_pool_t *pool, GHashFunc hash_func, GEqual
* @param key_equal_func pointer to function for comparing keys
* @return new rspamd_hash object
*/
-rspamd_hash_t* rspamd_hash_new_shared (memory_pool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_func);
+rspamd_hash_t* rspamd_hash_new_shared (memory_pool_t *pool, GHashFunc hash_func, GEqualFunc key_equal_func, gint size);
/**
* Insert item in hash
diff --git a/src/main.c b/src/main.c
index 2b56cd961..668c0d7cc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -575,7 +575,7 @@ main (int argc, char **argv, char **env)
rspamd->statfile_pool = statfile_pool_new (cfg->max_statfile_size);
/* Init counters */
- counters = rspamd_hash_new_shared (rspamd->server_pool, g_str_hash, g_str_equal);
+ counters = rspamd_hash_new_shared (rspamd->server_pool, g_str_hash, g_str_equal, 64);
for (i = 0; i < cfg->workers_number; i++) {
fork_worker (rspamd, listen_sock, TYPE_WORKER);
diff --git a/src/statfile.c b/src/statfile.c
index e41c1af15..008154194 100644
--- a/src/statfile.c
+++ b/src/statfile.c
@@ -110,7 +110,7 @@ statfile_pool_new (size_t max_size)
new->pool = memory_pool_new (memory_pool_get_size ());
new->max = max_size;
new->files = rspamd_hash_new (new->pool, g_str_hash, g_str_equal);
- new->maps = rspamd_hash_new_shared (new->pool, g_str_hash, g_str_equal);
+ new->maps = rspamd_hash_new_shared (new->pool, g_str_hash, g_str_equal, 64);
return new;
}