From 5ef1e00d3a37fabf6e44e55d8b325a488233be5d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 29 Jun 2010 08:51:26 -0500 Subject: [PATCH] LBAPR-4 --- src/switch_apr.c | 5 ----- src/switch_core_memory.c | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/switch_apr.c b/src/switch_apr.c index d579999356..ba44ad224a 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -89,11 +89,6 @@ SWITCH_DECLARE(int) switch_thread_equal(switch_thread_id_t tid1, switch_thread_i } -SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p) -{ - apr_pool_clear(p); -} - SWITCH_DECLARE(unsigned int) switch_ci_hashfunc_default(const char *char_key, switch_ssize_t *klen) { unsigned int hash = 0; diff --git a/src/switch_core_memory.c b/src/switch_core_memory.c index 42ef86a08f..39d0403c42 100644 --- a/src/switch_core_memory.c +++ b/src/switch_core_memory.c @@ -318,6 +318,29 @@ SWITCH_DECLARE(void) switch_core_memory_pool_tag(switch_memory_pool_t *pool, con apr_pool_tag(pool, tag); } +SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p) +{ +#ifdef PER_POOL_LOCK + apr_thread_mutex_t *my_mutex; + apr_pool_mutex_set(p, NULL); +#endif + + apr_pool_clear(p); + +#ifdef PER_POOL_LOCK + + if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_NESTED, p)) != APR_SUCCESS) { + abort(); + } + + apr_pool_mutex_set(p, my_mutex); + +#endif + +} + + + SWITCH_DECLARE(switch_status_t) switch_core_perform_new_memory_pool(switch_memory_pool_t **pool, const char *file, const char *func, int line) { char *tmp; @@ -503,6 +526,7 @@ static void *SWITCH_THREAD_FUNC pool_thread(switch_thread_t *thread, void *obj) switch_mutex_unlock(memory_manager.mem_lock); #endif #else + apr_pool_mutex_set(pop, NULL); apr_pool_clear(pop); if (switch_queue_trypush(memory_manager.pool_recycle_queue, pop) != SWITCH_STATUS_SUCCESS) { #ifdef USE_MEM_LOCK