[Freeswitch-svn] [commit] r9498 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Tue Sep 9 18:47:37 EDT 2008


Author: anthm
Date: Tue Sep  9 18:47:37 2008
New Revision: 9498

Modified:
   freeswitch/trunk/src/switch_xml.c

Log:
change xml hooks to rwlock

Modified: freeswitch/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/trunk/src/switch_xml.c	(original)
+++ freeswitch/trunk/src/switch_xml.c	Tue Sep  9 18:47:37 2008
@@ -139,8 +139,8 @@
 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 {
@@ -186,7 +186,8 @@
 	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) {
@@ -199,7 +200,7 @@
 		}
 		last = ptr;
 	}
-	switch_mutex_unlock(XML_LOCK);
+	switch_thread_rwlock_unlock(B_RWLOCK);
 
 	return status;
 }
@@ -209,7 +210,7 @@
 	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) {
@@ -221,7 +222,7 @@
 		}
 		last = ptr;
 	}
-	switch_mutex_unlock(XML_LOCK);
+	switch_thread_rwlock_unlock(B_RWLOCK);
 
 	return status;
 }
@@ -239,7 +240,7 @@
 	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) {
@@ -247,7 +248,7 @@
 	} else {
 		BINDINGS = binding;
 	}
-	switch_mutex_unlock(XML_LOCK);
+	switch_thread_rwlock_unlock(B_RWLOCK);
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -1363,7 +1364,7 @@
 	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);
@@ -1398,7 +1399,7 @@
 			}
 		}
 	}
-	switch_mutex_unlock(XML_LOCK);
+	switch_thread_rwlock_unlock(B_RWLOCK);
 
 	for (;;) {
 		if (!xml) {
@@ -1571,13 +1572,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);
@@ -1609,7 +1610,7 @@
 	if (hasmain) {
 		switch_thread_rwlock_unlock(RWLOCK);
 	}
-	switch_mutex_unlock(XML_LOCK);
+	//switch_mutex_unlock(XML_LOCK);
 
 	if (errcnt == 0) {
 		switch_event_t *event;
@@ -1630,8 +1631,9 @@
 	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);
 



More information about the Freeswitch-svn mailing list