diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-06-24 20:25:54 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-06-24 20:25:54 +0400 |
commit | a3fa4d672341fd2f1888d3a2f2ed85ae57913b78 (patch) | |
tree | 352c634bbbc74cf17644545ace66a8feedc841c3 /src/mem_pool.c | |
parent | 63725086863e4f422340479f83dd7ef374613e76 (diff) | |
download | rspamd-a3fa4d672341fd2f1888d3a2f2ed85ae57913b78.tar.gz rspamd-a3fa4d672341fd2f1888d3a2f2ed85ae57913b78.zip |
* Welcome 0.4.0
Uncompatible changes:
- Statistics is uncompatible in utf8 mode
Major changes:
- Improved utf8 mode
- Convert all characters to lowercase in statistics
- Skip URL's in statistics
- Improve speed of bayes classifier by using integer arithmetics
- Fixed statfiles synchronization that was broken for a long time
- Synchronization is now configurable
Minor changes:
- Bugfixes
- Removed some of legacy code
- Types polishing
Diffstat (limited to 'src/mem_pool.c')
-rw-r--r-- | src/mem_pool.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mem_pool.c b/src/mem_pool.c index 5c48b55ee..43ffc86a0 100644 --- a/src/mem_pool.c +++ b/src/mem_pool.c @@ -91,6 +91,7 @@ pool_chain_new (gsize size) chain->pos = align_ptr (chain->begin, MEM_ALIGNMENT); chain->next = NULL; STAT_LOCK (); + mem_pool_stat->bytes_allocated += size; mem_pool_stat->chunks_allocated++; STAT_UNLOCK (); @@ -135,6 +136,7 @@ pool_chain_new_shared (gsize size) chain->next = NULL; STAT_LOCK (); mem_pool_stat->shared_chunks_allocated++; + mem_pool_stat->bytes_allocated += size; STAT_UNLOCK (); return chain; @@ -225,16 +227,11 @@ memory_pool_alloc (memory_pool_t * pool, gsize size) cur->next = new; pool->cur_pool = new; new->pos += size; - STAT_LOCK (); - mem_pool_stat->bytes_allocated += size; - STAT_UNLOCK (); + return new->begin; } tmp = align_ptr (cur->pos, MEM_ALIGNMENT); cur->pos = tmp + size; - STAT_LOCK (); - mem_pool_stat->bytes_allocated += size; - STAT_UNLOCK (); return tmp; } return NULL; @@ -349,9 +346,6 @@ memory_pool_alloc_shared (memory_pool_t * pool, gsize size) } tmp = align_ptr (cur->pos, MEM_ALIGNMENT); cur->pos = tmp + size; - STAT_LOCK (); - mem_pool_stat->bytes_allocated += size; - STAT_UNLOCK (); return tmp; } return NULL; @@ -506,20 +500,22 @@ memory_pool_delete (memory_pool_t * pool) while (cur) { tmp = cur; cur = cur->next; - g_slice_free1 (tmp->len, tmp->begin); - g_slice_free (struct _pool_chain, tmp); STAT_LOCK (); mem_pool_stat->chunks_freed++; + mem_pool_stat->bytes_allocated -= tmp->len; STAT_UNLOCK (); + g_slice_free1 (tmp->len, tmp->begin); + g_slice_free (struct _pool_chain, tmp); } /* Unmap shared memory */ while (cur_shared) { tmp_shared = cur_shared; cur_shared = cur_shared->next; - munmap ((void *)tmp_shared, tmp_shared->len + sizeof (struct _pool_chain_shared)); STAT_LOCK (); mem_pool_stat->chunks_freed++; + mem_pool_stat->bytes_allocated -= tmp->len; STAT_UNLOCK (); + munmap ((void *)tmp_shared, tmp_shared->len + sizeof (struct _pool_chain_shared)); } if (pool->variables) { g_hash_table_destroy (pool->variables); |