提交 f6f7f31c authored 作者: Anthony Minessale's avatar Anthony Minessale

fix race in xml reloader

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9996 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 bed038a8
...@@ -142,8 +142,7 @@ static switch_memory_pool_t *XML_MEMORY_POOL = NULL; ...@@ -142,8 +142,7 @@ static switch_memory_pool_t *XML_MEMORY_POOL = NULL;
static switch_thread_rwlock_t *RWLOCK = NULL; static switch_thread_rwlock_t *RWLOCK = NULL;
static switch_thread_rwlock_t *B_RWLOCK = NULL; static switch_thread_rwlock_t *B_RWLOCK = NULL;
static switch_mutex_t *XML_LOCK = NULL; static switch_mutex_t *XML_LOCK = NULL;
static switch_mutex_t *XML_COUNT_LOCK = NULL;
static uint32_t lock_count = 0;
struct xml_section_t { struct xml_section_t {
const char *name; const char *name;
...@@ -1524,9 +1523,6 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key, ...@@ -1524,9 +1523,6 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
SWITCH_DECLARE(switch_xml_t) switch_xml_root(void) SWITCH_DECLARE(switch_xml_t) switch_xml_root(void)
{ {
switch_mutex_lock(XML_COUNT_LOCK);
lock_count++;
switch_mutex_unlock(XML_COUNT_LOCK);
switch_thread_rwlock_rdlock(RWLOCK); switch_thread_rwlock_rdlock(RWLOCK);
return MAIN_XML_ROOT; return MAIN_XML_ROOT;
} }
...@@ -1637,7 +1633,6 @@ SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool, cons ...@@ -1637,7 +1633,6 @@ SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool, cons
*err = "Success"; *err = "Success";
switch_mutex_init(&XML_LOCK, SWITCH_MUTEX_NESTED, XML_MEMORY_POOL); switch_mutex_init(&XML_LOCK, SWITCH_MUTEX_NESTED, XML_MEMORY_POOL);
switch_mutex_init(&XML_COUNT_LOCK, SWITCH_MUTEX_NESTED, XML_MEMORY_POOL);
switch_thread_rwlock_create(&RWLOCK, XML_MEMORY_POOL); switch_thread_rwlock_create(&RWLOCK, XML_MEMORY_POOL);
switch_thread_rwlock_create(&B_RWLOCK, XML_MEMORY_POOL); switch_thread_rwlock_create(&B_RWLOCK, XML_MEMORY_POOL);
...@@ -1926,19 +1921,12 @@ SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml) ...@@ -1926,19 +1921,12 @@ SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml)
char **a, *s; char **a, *s;
if (!xml) if (!xml) {
return; return;
if (switch_test_flag(xml, SWITCH_XML_ROOT)) {
switch_mutex_lock(XML_COUNT_LOCK);
if (lock_count > 0) {
switch_thread_rwlock_unlock(RWLOCK);
lock_count--;
}
switch_mutex_unlock(XML_COUNT_LOCK);
} }
if (xml == MAIN_XML_ROOT) { if (xml == MAIN_XML_ROOT) {
switch_thread_rwlock_unlock(RWLOCK);
return; return;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论