From 14415b29f1561fb52e10c70a3c5ab7673351094c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 21 Mar 2009 16:47:57 +0000 Subject: [PATCH] add mutex to global mem pool and tweak var code git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12705 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_channel.c | 12 ++++++------ src/switch_core_memory.c | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/switch_channel.c b/src/switch_channel.c index 7bf7571d75..b6ed57115a 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -485,7 +485,7 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *channel, const char *varname) { - const char *v = NULL; + const char *v = NULL, *r = NULL; switch_assert(channel != NULL); switch_mutex_lock(channel->profile_mutex); @@ -507,17 +507,17 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *chann } } - if (v) v = switch_core_session_strdup(channel->session, v); + if (v) r = switch_core_session_strdup(channel->session, v); switch_mutex_unlock(channel->profile_mutex); - return v; + return r; } SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname) { const char *uuid; - const char *val = NULL; + const char *val = NULL, *r = NULL; switch_assert(channel != NULL); if (!switch_strlen_zero(varname)) { @@ -531,9 +531,9 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_ } } - if (val) val = switch_core_session_strdup(channel->session, val); + if (val) r = switch_core_session_strdup(channel->session, val); - return val; + return r; } diff --git a/src/switch_core_memory.c b/src/switch_core_memory.c index d16e1159c5..395c6cadfd 100644 --- a/src/switch_core_memory.c +++ b/src/switch_core_memory.c @@ -569,11 +569,12 @@ switch_memory_pool_t *switch_core_memory_init(void) abort(); } - if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_DEFAULT, memory_manager.memory_pool)) != APR_SUCCESS) { + if ((apr_thread_mutex_create(&my_mutex, APR_THREAD_MUTEX_NESTED, memory_manager.memory_pool)) != APR_SUCCESS) { abort(); } apr_allocator_mutex_set(my_allocator, my_mutex); + apr_pool_mutex_set(memory_manager.memory_pool, my_mutex); apr_allocator_owner_set(my_allocator, memory_manager.memory_pool); #else apr_pool_create(&memory_manager.memory_pool, NULL);