[Freeswitch-svn] [commit] r9210 - in freeswitch/trunk/src: . include

Freeswitch SVN anthm at freeswitch.org
Wed Jul 30 14:54:37 EDT 2008


Author: anthm
Date: Wed Jul 30 14:54:37 2008
New Revision: 9210

Modified:
   freeswitch/trunk/src/include/switch_xml.h
   freeswitch/trunk/src/switch_xml.c

Log:
update

Modified: freeswitch/trunk/src/include/switch_xml.h
==============================================================================
--- freeswitch/trunk/src/include/switch_xml.h	(original)
+++ freeswitch/trunk/src/include/switch_xml.h	Wed Jul 30 14:54:37 2008
@@ -215,6 +215,7 @@
 ///\param xml the xml node
 ///\note in the case of the root node the readlock will be lifted
 SWITCH_DECLARE(void) switch_xml_free(switch_xml_t xml);
+SWITCH_DECLARE(void) switch_xml_free_in_thread(switch_xml_t xml, int stacksize);
 
 ///\brief returns parser error message or empty string if none
 ///\param xml the xml node

Modified: freeswitch/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/trunk/src/switch_xml.c	(original)
+++ freeswitch/trunk/src/switch_xml.c	Wed Jul 30 14:54:37 2008
@@ -1523,6 +1523,43 @@
 	return MAIN_XML_ROOT;
 }
 
+
+struct destroy_xml {
+	switch_xml_t xml;
+	switch_memory_pool_t *pool;
+};
+
+static void *SWITCH_THREAD_FUNC destroy_thread(switch_thread_t *thread, void *obj)
+{
+	struct destroy_xml *dx = (struct destroy_xml *) obj;
+	switch_memory_pool_t *pool = dx->pool;
+	switch_xml_free(dx->xml);
+	switch_core_destroy_memory_pool(&pool);
+	return NULL;
+}
+
+SWITCH_DECLARE(void) switch_xml_free_in_thread(switch_xml_t xml, int stacksize)
+{
+	switch_thread_t *thread;
+    switch_threadattr_t *thd_attr;
+	switch_memory_pool_t *pool = NULL;
+	struct destroy_xml *dx;
+
+	switch_core_new_memory_pool(&pool);
+
+	switch_threadattr_create(&thd_attr, pool);
+    switch_threadattr_detach_set(thd_attr, 1);
+	// TBD figure out how much space we need by looking at the xml_t when stacksize == 0
+    switch_threadattr_stacksize_set(thd_attr, stacksize);
+
+	dx = switch_core_alloc(pool, sizeof(*dx));
+	dx->pool = pool;
+	dx->xml = xml;
+
+	switch_thread_create(&thread, thd_attr, destroy_thread, dx, pool);
+
+}
+
 static char not_so_threadsafe_error_buffer[256] = "";
 
 SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **err)
@@ -1559,6 +1596,7 @@
 			MAIN_XML_ROOT = new_main;
 			switch_set_flag(MAIN_XML_ROOT, SWITCH_XML_ROOT);
 			switch_xml_free(old_root);
+			//switch_xml_free_in_thread(old_root);
 		}
 	} else {
 		*err = "Cannot Open log directory or XML Root!";



More information about the Freeswitch-svn mailing list