]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 30 Jul 2008 18:54:37 +0000 (18:54 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 30 Jul 2008 18:54:37 +0000 (18:54 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9210 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_xml.h
src/switch_xml.c

index b7493ea1bcd7059850a331189175bf42633a874b..be8a2e62f14e5006ab564835abe86eedcd66955f 100644 (file)
@@ -215,6 +215,7 @@ SWITCH_DECLARE(const char **) switch_xml_pi(switch_xml_t xml, const char *target
 ///\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
index 4793e8847c20a4b095e05a63b5c22f599c65146e..6f4aeedb46c3c1e3813535eb1fb5187d4f4ecdc3 100644 (file)
@@ -1523,6 +1523,43 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_root(void)
        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 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **e
                        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!";