]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
prevent exclusive hold on xml registry during visits to the phrase section
authorMichael Jerris <mike@jerris.com>
Thu, 12 Feb 2009 00:27:07 +0000 (00:27 +0000)
committerMichael Jerris <mike@jerris.com>
Thu, 12 Feb 2009 00:27:07 +0000 (00:27 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11900 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_xml.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_sofia/sofia.c
src/switch_ivr_play_say.c
src/switch_xml.c

index 34b84466b68bd754fccd97cd115d632061f8d4aa..a1f2264706c00c670505234ad5ee6d7950d862b3 100644 (file)
@@ -331,8 +331,12 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_root(void);
 ///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned
 SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
                                                                                                  const char *tag_name,
-                                                                                                 const char *key_name, const char *key_value, switch_xml_t *root, switch_xml_t *node,
-                                                                                                 switch_event_t *params);
+                                                                                                 const char *key_name, 
+                                                                                                 const char *key_value, 
+                                                                                                 switch_xml_t *root, 
+                                                                                                 switch_xml_t *node,
+                                                                                                 switch_event_t *params,
+                                                                                                 switch_bool_t clone);
 
 SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(const char *domain_name, switch_event_t *params, switch_xml_t *root, switch_xml_t *domain);
 
index 6302a79a6417d96f3bc70d84d5b013e420dad988..a863f91df9894dcc5cd19c2cefd2661634cec63f 100644 (file)
@@ -669,7 +669,7 @@ SWITCH_STANDARD_API(xml_locate_function)
        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag_attr_name", tag_attr_name);
        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag_attr_val", tag_attr_val);
 
-       if (switch_xml_locate(section, tag, tag_attr_name, tag_attr_val, &xml, &obj, params) != SWITCH_STATUS_SUCCESS) {
+       if (switch_xml_locate(section, tag, tag_attr_name, tag_attr_val, &xml, &obj, params, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
                stream->write_function(stream, "can't find anything\n");
                goto end;
        }
index f75f94a6478119beb7739eb6f3d295849c58d0da..33245020b331f9600290ae172685b125a3131cc4 100644 (file)
@@ -206,8 +206,7 @@ static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switc
 
        switch_channel_event_set_data(channel, params);
        switch_caller_profile_event_set_data(caller_profile, "Hunt", params);
-
-       status = switch_xml_locate("dialplan", NULL, NULL, NULL, root, node, params);
+       status = switch_xml_locate("dialplan", NULL, NULL, NULL, root, node, params, SWITCH_FALSE);
        switch_event_destroy(&params);
        return status;
 }
index 1a81d879489d444dda400c04e1b8bd458d008ed6..532c8a4844f9682fefb1509138035be67960d15d 100644 (file)
@@ -2277,7 +2277,7 @@ static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "from", from);
        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "object", "vcard");
 
-       if (switch_xml_locate("directory", "domain", "name", to_host, &xml, &domain, params) != SWITCH_STATUS_SUCCESS) {
+       if (switch_xml_locate("directory", "domain", "name", to_host, &xml, &domain, params, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
                //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "can't find domain for [%s@%s]\n", to_user, to_host);
                goto end;
        }
index 80e0b70c3f123827e2192b9d22b2ba1fe013d652..209780b13d3dcf5955553283a483f75aacbb309f 100644 (file)
@@ -1653,7 +1653,7 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
                                        if (!switch_strlen_zero(dname)) {
                                                if (!strcasecmp(dname, "all")) {
                                                        switch_xml_t xml_root, x_domains;
-                                                       if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params) == SWITCH_STATUS_SUCCESS) {
+                                                       if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
                                                                for (x_domain_tag = switch_xml_child(x_domains, "domain"); x_domain_tag; x_domain_tag = x_domain_tag->next) {
                                                                        dname = switch_xml_attr_soft(x_domain_tag, "name");
                                                                        parse_domain_tag(profile, x_domain_tag, dname, parse, alias);
@@ -2361,7 +2361,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                if (!switch_strlen_zero(dname)) {
                                                        if (!strcasecmp(dname, "all")) {
                                                                switch_xml_t xml_root, x_domains;
-                                                               if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params) == SWITCH_STATUS_SUCCESS) {
+                                                               if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
                                                                        for (x_domain_tag = switch_xml_child(x_domains, "domain"); x_domain_tag; x_domain_tag = x_domain_tag->next) {
                                                                                dname = switch_xml_attr_soft(x_domain_tag, "name");
                                                                                parse_domain_tag(profile, x_domain_tag, dname, parse, alias);
index fd3e351a857472a3d9e8b69354d708c9fe436074..580576b42041f923620573d818d4c3c35ce9b503 100644 (file)
@@ -133,7 +133,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
        }
        switch_channel_event_set_data(channel, hint_data);
 
-       if (switch_xml_locate("phrases", NULL, NULL, NULL, &xml, &cfg, hint_data) != SWITCH_STATUS_SUCCESS) {
+       if (switch_xml_locate("phrases", NULL, NULL, NULL, &xml, &cfg, hint_data, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of phrases failed.\n");
                goto done;
        }
index 0be807192897887aa38c10424493738e1e0d918e..5d9283c4a3beef69e15ab07b2a255e9f58586925 100644 (file)
@@ -1491,8 +1491,12 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file)
 
 SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
                                                                                                  const char *tag_name,
-                                                                                                 const char *key_name, const char *key_value, switch_xml_t * root, switch_xml_t * node,
-                                                                                                 switch_event_t *params)
+                                                                                                 const char *key_name, 
+                                                                                                 const char *key_value, 
+                                                                                                 switch_xml_t *root, 
+                                                                                                 switch_xml_t *node,
+                                                                                                 switch_event_t *params,
+                                                                                                 switch_bool_t clone)
 {
        switch_xml_t conf = NULL;
        switch_xml_t tag = NULL;
@@ -1547,8 +1551,16 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
                }
 
                if ((conf = switch_xml_find_child(xml, "section", "name", section)) && (tag = switch_xml_find_child(conf, tag_name, key_name, key_value))) {
-                       *node = tag;
-                       *root = xml;
+                       if (clone) {
+                               char *x = switch_xml_toxml(tag, SWITCH_FALSE);
+                               switch_assert(x);
+                               *root = switch_xml_parse_str(x, strlen(x));
+                               *node = *root;
+                               switch_xml_free(xml);
+                       } else {
+                               *node = tag;
+                               *root = xml;
+                       }
                        return SWITCH_STATUS_SUCCESS;
                } else {
                        switch_xml_free(xml);
@@ -1577,7 +1589,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(const char *domain_name
                params = my_params;
        }
 
-       status = switch_xml_locate("directory", "domain", "name", domain_name, root, domain, params);
+       status = switch_xml_locate("directory", "domain", "name", domain_name, root, domain, params, SWITCH_FALSE);
        if (my_params) {
                switch_event_destroy(&my_params);
        }
@@ -1914,7 +1926,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_cfg(const char *file_path, switch_x
 
        assert(MAIN_XML_ROOT != NULL);
 
-       if (switch_xml_locate("configuration", "configuration", "name", file_path, &xml, &cfg, params) == SWITCH_STATUS_SUCCESS) {
+       if (switch_xml_locate("configuration", "configuration", "name", file_path, &xml, &cfg, params, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
                *node = cfg;
        }