From 42c9df72ce2c1653b4c7def98336d848dacfb2c5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 16 Sep 2010 17:38:06 -0500 Subject: [PATCH] ***BEHAVIOUR CHANGE*** reloadacl, load , reload will now explicitly call reloadxml --- src/include/switch_xml.h | 1 + .../applications/mod_commands/mod_commands.c | 35 +++++++++++-------- src/switch_xml.c | 12 +++++++ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index 220e65df02..9b0fbb44f3 100644 --- a/src/include/switch_xml.h +++ b/src/include/switch_xml.h @@ -331,6 +331,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(_In_ uint8_t reload, _Out_ con ///\return SWITCH_STATUS_SUCCESS if successful SWITCH_DECLARE(switch_status_t) switch_xml_init(_In_ switch_memory_pool_t *pool, _Out_ const char **err); +SWITCH_DECLARE(switch_status_t) switch_xml_reload(const char **err); SWITCH_DECLARE(switch_status_t) switch_xml_destroy(void); diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 0865b2b511..d87e82047b 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1179,17 +1179,18 @@ SWITCH_STANDARD_API(xml_locate_function) SWITCH_STANDARD_API(reload_acl_function) { const char *err; - switch_xml_t xml_root; - if (cmd && !strcmp(cmd, "reloadxml")) { - if ((xml_root = switch_xml_open_root(1, &err))) { - switch_xml_free(xml_root); - } + if (cmd && !strcasecmp(cmd, "reloadxml")) { + stream->write_function(stream, "This option is depricated, we now always reloadxml.\n"); + } + + if (switch_xml_reload(&err) == SWITCH_STATUS_SUCCESS) { + switch_load_network_lists(SWITCH_TRUE); + stream->write_function(stream, "+OK acl reloaded\n"); + } else { + stream->write_function(stream, "-Error [%s]\n", err); } - switch_load_network_lists(SWITCH_TRUE); - - stream->write_function(stream, "+OK acl reloaded\n"); return SWITCH_STATUS_SUCCESS; } @@ -1738,6 +1739,10 @@ SWITCH_STANDARD_API(load_function) return SWITCH_STATUS_SUCCESS; } + if (switch_xml_reload(&err) == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+OK Reloading XML\n"); + } + if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "+OK\n"); } else { @@ -1832,6 +1837,10 @@ SWITCH_STANDARD_API(reload_function) stream->write_function(stream, "-ERR unloading module [%s]\n", err); } + if (switch_xml_reload(&err) == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+OK Reloading XML\n"); + } + if (switch_loadable_module_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) cmd, SWITCH_TRUE, &err) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "+OK module loaded\n"); } else { @@ -1843,13 +1852,9 @@ SWITCH_STANDARD_API(reload_function) SWITCH_STANDARD_API(reload_xml_function) { - const char *err; - switch_xml_t xml_root; - - if ((xml_root = switch_xml_open_root(1, &err))) { - switch_xml_free(xml_root); - } + const char *err = ""; + switch_xml_reload(&err); stream->write_function(stream, "+OK [%s]\n", err); return SWITCH_STATUS_SUCCESS; @@ -4569,7 +4574,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "originate", "Originate a Call", originate_function, ORIGINATE_SYNTAX); SWITCH_ADD_API(commands_api_interface, "pause", "Pause", pause_function, PAUSE_SYNTAX); SWITCH_ADD_API(commands_api_interface, "regex", "Eval a regex", regex_function, "|[|]"); - SWITCH_ADD_API(commands_api_interface, "reloadacl", "Reload ACL", reload_acl_function, "[reloadxml]"); + SWITCH_ADD_API(commands_api_interface, "reloadacl", "Reload ACL", reload_acl_function, ""); SWITCH_ADD_API(commands_api_interface, "reload", "Reload Module", reload_function, UNLOAD_SYNTAX); SWITCH_ADD_API(commands_api_interface, "reloadxml", "Reload XML", reload_xml_function, ""); SWITCH_ADD_API(commands_api_interface, "replace", "replace a string", replace_function, "||"); diff --git a/src/switch_xml.c b/src/switch_xml.c index efaede83fb..688978907f 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -2039,6 +2039,18 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **e return r; } +SWITCH_DECLARE(switch_status_t) switch_xml_reload(const char **err) +{ + switch_xml_t xml_root; + + if ((xml_root = switch_xml_open_root(1, err))) { + switch_xml_free(xml_root); + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_GENERR; +} + SWITCH_DECLARE(switch_status_t) switch_xml_init(switch_memory_pool_t *pool, const char **err) { switch_xml_t xml;