diff options
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); } |