From 57317dffffc9b5173495b6d3fe0f25cf4c74212a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 26 Jan 2008 01:53:42 +0000 Subject: [PATCH] prevent invalid state change git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7365 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 4 +++- src/mod/endpoints/mod_sofia/sofia.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 927f834d28..d603146d7e 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1808,7 +1808,9 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session switch_channel_set_flag(nchannel, CF_OUTBOUND); switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION); - switch_channel_set_state(nchannel, CS_INIT); + if (switch_channel_get_state(nchannel) == CS_NEW) { + switch_channel_set_state(nchannel, CS_INIT); + } tech_pvt->caller_profile = caller_profile; *new_session = nsession; cause = SWITCH_CAUSE_SUCCESS; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 3859b84a9e..bc13043fc3 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1530,7 +1530,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) { switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOMEDIA"); switch_set_flag_locked(tech_pvt, TFLAG_READY); - switch_channel_set_state(channel, CS_INIT); + if (switch_channel_get_state(channel) == CS_NEW) { + switch_channel_set_state(channel, CS_INIT); + } switch_set_flag(tech_pvt, TFLAG_SDP); goto done; } else { @@ -1553,7 +1555,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, su_home_t *home = NULL; switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED"); switch_set_flag_locked(tech_pvt, TFLAG_READY); - switch_channel_set_state(channel, CS_INIT); + if (switch_channel_get_state(channel) == CS_NEW) { + switch_channel_set_state(channel, CS_INIT); + } switch_set_flag(tech_pvt, TFLAG_SDP); if (replaces_str) { home = su_home_new(sizeof(*home)); @@ -1748,7 +1752,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } if (switch_channel_get_state(channel) == CS_HIBERNATE) { switch_set_flag_locked(tech_pvt, TFLAG_READY); - switch_channel_set_state(channel, CS_INIT); + if (switch_channel_get_state(channel) == CS_NEW) { + switch_channel_set_state(channel, CS_INIT); + } switch_set_flag(tech_pvt, TFLAG_SDP); } goto done;