aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/mem_pool.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-24 21:49:09 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-24 21:49:09 +0100
commitc2750a8864dc0c0aa31f779d3841487b62408b6a (patch)
tree0c9c708b94d2417db50fb71f7778993e19879891 /src/libutil/mem_pool.c
parent12594e3596b115b7dd2c83bed0714456d47b7aef (diff)
downloadrspamd-c2750a8864dc0c0aa31f779d3841487b62408b6a.tar.gz
rspamd-c2750a8864dc0c0aa31f779d3841487b62408b6a.zip
[Minor] Add some limits for auto mempool adjustment
Diffstat (limited to 'src/libutil/mem_pool.c')
-rw-r--r--src/libutil/mem_pool.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c
index 9856e9198..4a2f54b64 100644
--- a/src/libutil/mem_pool.c
+++ b/src/libutil/mem_pool.c
@@ -403,6 +403,7 @@ memory_pool_alloc_common (rspamd_mempool_t * pool, gsize size,
if (cur == NULL || free < size) {
/* Allocate new chain element */
if (pool->elt_len >= size + MEM_ALIGNMENT) {
+ pool->entry->elts[pool->entry->cur_elts].fragmentation += size;
new = rspamd_mempool_chain_new (pool->elt_len + MEM_ALIGNMENT,
pool_type);
}
@@ -632,6 +633,14 @@ rspamd_mempool_adjust_entry (struct rspamd_mempool_entry_point *e)
e->cur_suggestion *= (1 + (((double)sel_pos) / e->cur_suggestion)) * 1.5;
}
+ /* Some sane limits counting mempool architecture */
+ if (e->cur_suggestion < 1024) {
+ e->cur_suggestion = 1024;
+ }
+ else if (e->cur_suggestion > 1024 * 1024 * 10) {
+ e->cur_suggestion = 1024 * 1024 * 10;
+ }
+
memset (e->elts, 0, sizeof (e->elts));
}