[Freeswitch-svn] [commit] r9499 - freeswitch/trunk/src
Freeswitch SVN
anthm at freeswitch.org
Tue Sep 9 19:14:16 EDT 2008
Author: anthm
Date: Tue Sep 9 19:14:15 2008
New Revision: 9499
Modified:
freeswitch/trunk/src/switch_xml.c
Log:
declinatio mortuus obfirmo!
Modified: freeswitch/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/trunk/src/switch_xml.c (original)
+++ freeswitch/trunk/src/switch_xml.c Tue Sep 9 19:14:15 2008
@@ -138,9 +138,11 @@
static switch_xml_binding_t *BINDINGS = NULL;
static switch_xml_t MAIN_XML_ROOT = NULL;
-static switch_memory_pool_t *XML_MEMORY_POOL;
-static switch_thread_rwlock_t *RWLOCK;
-static switch_thread_rwlock_t *B_RWLOCK;
+static switch_memory_pool_t *XML_MEMORY_POOL = NULL;
+static switch_thread_rwlock_t *RWLOCK = NULL;
+static switch_thread_rwlock_t *B_RWLOCK = 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 {
@@ -1522,7 +1524,9 @@
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);
return MAIN_XML_ROOT;
}
@@ -1572,13 +1576,13 @@
uint8_t hasmain = 0, errcnt = 0;
switch_xml_t new_main;
- //switch_mutex_lock(XML_LOCK);
+ switch_mutex_lock(XML_LOCK);
if (MAIN_XML_ROOT) {
hasmain++;
if (!reload) {
- //switch_mutex_unlock(XML_LOCK);
+ switch_mutex_unlock(XML_LOCK);
return switch_xml_root();
}
switch_thread_rwlock_wrlock(RWLOCK);
@@ -1610,7 +1614,8 @@
if (hasmain) {
switch_thread_rwlock_unlock(RWLOCK);
}
- //switch_mutex_unlock(XML_LOCK);
+
+ switch_mutex_unlock(XML_LOCK);
if (errcnt == 0) {
switch_event_t *event;
@@ -1631,7 +1636,8 @@
XML_MEMORY_POOL = pool;
*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(&B_RWLOCK, XML_MEMORY_POOL);
@@ -1924,10 +1930,12 @@
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) {
More information about the Freeswitch-svn
mailing list