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_mutex_t *XML_LOCK;
static switch_thread_rwlock_t *RWLOCK;
+static switch_thread_rwlock_t *B_RWLOCK;
static uint32_t lock_count = 0;
struct xml_section_t {
switch_xml_binding_t *ptr, *last = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
- switch_mutex_lock(XML_LOCK);
+
+ switch_thread_rwlock_wrlock(B_RWLOCK);
for (ptr = BINDINGS; ptr; ptr = ptr->next) {
if (ptr == *binding) {
if (last) {
}
last = ptr;
}
- switch_mutex_unlock(XML_LOCK);
+ switch_thread_rwlock_unlock(B_RWLOCK);
return status;
}
switch_xml_binding_t *ptr, *last = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
- switch_mutex_lock(XML_LOCK);
+ switch_thread_rwlock_wrlock(B_RWLOCK);
for (ptr = BINDINGS; ptr; ptr = ptr->next) {
if (ptr->function == function) {
if (last) {
}
last = ptr;
}
- switch_mutex_unlock(XML_LOCK);
+ switch_thread_rwlock_unlock(B_RWLOCK);
return status;
}
binding->sections = sections;
binding->user_data = user_data;
- switch_mutex_lock(XML_LOCK);
+ switch_thread_rwlock_wrlock(B_RWLOCK);
for (ptr = BINDINGS; ptr && ptr->next; ptr = ptr->next);
if (ptr) {
} else {
BINDINGS = binding;
}
- switch_mutex_unlock(XML_LOCK);
+ switch_thread_rwlock_unlock(B_RWLOCK);
return SWITCH_STATUS_SUCCESS;
}
switch_xml_binding_t *binding;
uint8_t loops = 0;
- switch_mutex_lock(XML_LOCK);
+ switch_thread_rwlock_rdlock(B_RWLOCK);
for (binding = BINDINGS; binding; binding = binding->next) {
switch_xml_section_t sections = switch_xml_parse_section_string(section);
}
}
}
- switch_mutex_unlock(XML_LOCK);
+ switch_thread_rwlock_unlock(B_RWLOCK);
for (;;) {
if (!xml) {
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);
if (hasmain) {
switch_thread_rwlock_unlock(RWLOCK);
}
- switch_mutex_unlock(XML_LOCK);
+ //switch_mutex_unlock(XML_LOCK);
if (errcnt == 0) {
switch_event_t *event;
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_thread_rwlock_create(&RWLOCK, XML_MEMORY_POOL);
+ switch_thread_rwlock_create(&B_RWLOCK, XML_MEMORY_POOL);
assert(pool != NULL);