return SWITCH_STATUS_SUCCESS;
}
+
+static switch_status_t reload_function(char *mod, switch_stream_handle_t *stream)
+{
+ const char *err;
+ switch_xml_t xml_root;
+
+ if ((xml_root = switch_xml_open_root(1, &err))) {
+ switch_xml_free(xml_root);
+ }
+
+ stream->write_function(stream, "OK [%s]\n", err);
+ return SWITCH_STATUS_SUCCESS;
+}
+
static switch_status_t kill_function(char *dest, switch_stream_handle_t *stream)
{
switch_core_session_t *session = NULL;
/*.next */ &transfer_api_interface
};
+static switch_api_interface_t reload_api_interface = {
+ /*.interface_name */ "reloadxml",
+ /*.desc */ "Reload XML",
+ /*.function */ reload_function,
+ /*.next */ &load_api_interface,
+
+};
static switch_api_interface_t commands_api_interface = {
/*.interface_name */ "killchan",
/*.desc */ "Kill Channel",
/*.function */ kill_function,
- /*.next */ &load_api_interface
+ /*.next */ &reload_api_interface
};
static const switch_loadable_module_interface_t mod_commands_module_interface = {
static switch_memory_pool_t *XML_MEMORY_POOL;
static switch_mutex_t *XML_LOCK;
static switch_thread_rwlock_t *RWLOCK;
+static uint32_t lock_count = 0;
struct xml_section_t {
const char *name;
for(;;) {
if (!xml) {
- if (!(xml = MAIN_XML_ROOT)) {
+ if (!(xml = switch_xml_root())) {
*node = NULL;
*root = NULL;
return SWITCH_STATUS_FALSE;
return SWITCH_STATUS_FALSE;
}
+
SWITCH_DECLARE(switch_xml_t) switch_xml_root(void)
{
+ lock_count++;
switch_thread_rwlock_rdlock(RWLOCK);
return MAIN_XML_ROOT;
}
{
char path_buf[1024];
uint8_t hasmain = 0;
-
+
switch_mutex_lock(XML_LOCK);
if (MAIN_XML_ROOT) {
switch_xml_free(MAIN_XML_ROOT);
MAIN_XML_ROOT = NULL;
} else {
+ *err = "Success";
switch_set_flag(MAIN_XML_ROOT, SWITCH_XML_ROOT);
}
} else {
switch_thread_rwlock_unlock(RWLOCK);
}
switch_mutex_unlock(XML_LOCK);
+
return switch_xml_root();
}
if (! xml ) return;
if (switch_test_flag(xml, SWITCH_XML_ROOT)) {
- switch_thread_rwlock_unlock(RWLOCK);
+ if (lock_count > 0) {
+ switch_thread_rwlock_unlock(RWLOCK);
+ lock_count--;
+ }
}
if (xml == MAIN_XML_ROOT) {