From 277c1141c4021f5b6cceceed9e5d1a063b86338c Mon Sep 17 00:00:00 2001 From: root Date: Wed, 4 Apr 2012 17:20:35 -0500 Subject: [PATCH] a few perf tweaks --- src/include/switch_xml.h | 2 +- src/mod/endpoints/mod_sofia/sofia_glue.c | 2 +- src/switch_channel.c | 5 ++--- src/switch_core_io.c | 14 +++++++------- src/switch_xml.c | 12 +++++++++++- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index 0d436fac2f..558b8522f4 100644 --- a/src/include/switch_xml.h +++ b/src/include/switch_xml.h @@ -214,7 +214,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_get(_In_ switch_xml_t xml,...); ///\param prn_header add header too ///\return the xml text string SWITCH_DECLARE(char *) switch_xml_toxml(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header); - +SWITCH_DECLARE(char *) switch_xml_toxml_nolock(switch_xml_t xml, _In_ switch_bool_t prn_header); ///\brief Converts an switch_xml structure back to xml using the buffer passed in the parameters. ///\param xml the xml node ///\param buf buffer to use diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 0d7d3ac6e1..5786ec8f14 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -5971,7 +5971,7 @@ void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *sess } if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { - xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE); + xml_cdr_text = switch_xml_toxml_nolock(cdr, SWITCH_FALSE); switch_xml_free(cdr); } diff --git a/src/switch_channel.c b/src/switch_channel.c index 76161bc9c5..b15b0948a7 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1868,12 +1868,11 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state( switch_channel_clear_flag(channel, CF_TAGGED); - - switch_mutex_lock(channel->state_mutex); - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s\n", channel->name, state_names[state]); + switch_mutex_lock(channel->state_mutex); + channel->running_state = state; if (state == CS_ROUTING || state == CS_HANGUP) { diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 8b147327a2..952b345e67 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -41,7 +41,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor switch_io_event_hook_video_write_frame_t *ptr; switch_status_t status = SWITCH_STATUS_FALSE; - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -65,7 +65,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core switch_assert(session != NULL); - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -153,7 +153,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi } } - if (switch_channel_down_nosig(session->channel) || !switch_core_codec_ready(session->read_codec)) { + if (switch_channel_down(session->channel) || !switch_core_codec_ready(session->read_codec)) { *frame = NULL; status = SWITCH_STATUS_FALSE; goto even_more_done; @@ -1114,7 +1114,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess while (switch_buffer_inuse(session->raw_write_buffer) >= session->write_impl.decoded_bytes_per_packet) { int rate; - if (switch_channel_down_nosig(session->channel) || !session->raw_write_buffer) { + if (switch_channel_down(session->channel) || !session->raw_write_buffer) { goto error; } if ((session->raw_write_frame.datalen = (uint32_t) @@ -1296,7 +1296,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(switch_core_sessio switch_dtmf_t new_dtmf; int fed = 0; - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -1339,7 +1339,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio switch_status_t status = SWITCH_STATUS_FALSE; switch_dtmf_t new_dtmf; - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -1418,7 +1418,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core dtmf.flags = 0; } - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } diff --git a/src/switch_xml.c b/src/switch_xml.c index 2c687839c8..ce85efad4c 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -2451,12 +2451,22 @@ static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, } } +SWITCH_DECLARE(char *) switch_xml_toxml_nolock(switch_xml_t xml, switch_bool_t prn_header) +{ + char *s = (char *) malloc(SWITCH_XML_BUFSIZE); + switch_assert(s); + return switch_xml_toxml_buf(xml, s, SWITCH_XML_BUFSIZE, 0, prn_header); +} + + SWITCH_DECLARE(char *) switch_xml_toxml(switch_xml_t xml, switch_bool_t prn_header) { char *r, *s; - switch_mutex_lock(XML_GEN_LOCK); + s = (char *) malloc(SWITCH_XML_BUFSIZE); switch_assert(s); + + switch_mutex_lock(XML_GEN_LOCK); r = switch_xml_toxml_buf(xml, s, SWITCH_XML_BUFSIZE, 0, prn_header); switch_mutex_unlock(XML_GEN_LOCK); return r;