From 1ba98b02b9b2a44d1504f5c4546a7088907ed4eb Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 1 Dec 2010 09:54:28 -0600 Subject: [PATCH] FS-2852 --- src/switch_xml.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/switch_xml.c b/src/switch_xml.c index a7bfe413d0..05cfe9fd4c 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -1980,19 +1980,16 @@ static char not_so_threadsafe_error_buffer[256] = ""; SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **err) { char path_buf[1024]; - uint8_t hasmain = 0, errcnt = 0; + uint8_t errcnt = 0; switch_xml_t new_main, r = NULL; switch_mutex_lock(XML_LOCK); if (MAIN_XML_ROOT) { - hasmain++; - if (!reload) { r = switch_xml_root(); goto done; } - switch_thread_rwlock_wrlock(RWLOCK); } switch_snprintf(path_buf, sizeof(path_buf), "%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, "freeswitch.xml"); @@ -2007,9 +2004,15 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **e } else { switch_xml_t old_root; *err = "Success"; + + switch_thread_rwlock_wrlock(RWLOCK); + old_root = MAIN_XML_ROOT; MAIN_XML_ROOT = new_main; switch_set_flag(MAIN_XML_ROOT, SWITCH_XML_ROOT); + + switch_thread_rwlock_unlock(RWLOCK); + switch_xml_free(old_root); /* switch_xml_free_in_thread(old_root); */ } @@ -2018,10 +2021,6 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **e errcnt++; } - if (hasmain) { - switch_thread_rwlock_unlock(RWLOCK); - } - if (errcnt == 0) { switch_event_t *event; if (switch_event_create(&event, SWITCH_EVENT_RELOADXML) == SWITCH_STATUS_SUCCESS) {