diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-07-08 20:07:07 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-07-08 20:07:07 +0400 |
commit | 3d1c40c972d68623f88875ec03ae7c8bafbadad5 (patch) | |
tree | 75a34069f368ebb52b47e8c3f605dcde1de3e9cd /src/mem_pool.c | |
parent | 75bf13b9bda0d1eb98671b68064becd4f6946c14 (diff) | |
download | rspamd-3d1c40c972d68623f88875ec03ae7c8bafbadad5.tar.gz rspamd-3d1c40c972d68623f88875ec03ae7c8bafbadad5.zip |
* Make DNS resolver working
* Many improvements to rspamd test suite: now it CAN be used for testing rspamd functionality
* Write DNS resolver tests
* Fix issues with memory_pool mutexes and with creating of statfiles
Diffstat (limited to 'src/mem_pool.c')
-rw-r--r-- | src/mem_pool.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mem_pool.c b/src/mem_pool.c index 8d5c22ad1..3398cbf41 100644 --- a/src/mem_pool.c +++ b/src/mem_pool.c @@ -86,7 +86,6 @@ pool_chain_new_shared (memory_pool_ssize_t size) chain = (struct _pool_chain_shared *)mmap (NULL, size + sizeof (struct _pool_chain_shared), PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); g_assert (chain != MAP_FAILED); chain->begin = ((u_char *) chain) + sizeof (struct _pool_chain_shared); - g_assert (chain->begin != MAP_FAILED); #elif defined(HAVE_MMAP_ZERO) int fd; @@ -97,13 +96,12 @@ pool_chain_new_shared (memory_pool_ssize_t size) chain = (struct _pool_chain_shared *)mmap (NULL, size + sizeof (struct _pool_chain_shared), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); g_assert (chain != MAP_FAILED); chain->begin = ((u_char *) chain) + sizeof (struct _pool_chain_shared); - g_assert (chain->begin != MAP_FAILED); #else # error No mmap methods are defined #endif chain->len = size; chain->pos = chain->begin; - chain->lock = 0; + chain->lock = NULL; chain->next = NULL; STAT_LOCK (); mem_pool_stat->shared_chunks_allocated++; @@ -387,7 +385,9 @@ memory_pool_lock_shared (memory_pool_t * pool, void *pointer) if (chain == NULL) { return; } - + if (chain->lock == NULL) { + chain->lock = memory_pool_get_mutex (pool); + } memory_pool_lock_mutex (chain->lock); } @@ -400,6 +400,10 @@ memory_pool_unlock_shared (memory_pool_t * pool, void *pointer) if (chain == NULL) { return; } + if (chain->lock == NULL) { + chain->lock = memory_pool_get_mutex (pool); + return; + } memory_pool_unlock_mutex (chain->lock); } |