FS-9506 code was too over-zealous about taking control when it should not, pass 2

This commit is contained in:
Anthony Minessale 2016-09-13 15:54:55 -05:00
parent aee02a3041
commit 92644dbb4d

View File

@ -7689,19 +7689,23 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
} }
goto done; goto done;
} else { } else {
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_NEGOTIATED)) { int hold_related = 0;
nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
goto done; if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
hold_related = 2;
} else if (switch_stristr("sendonly", r_sdp) || switch_stristr("0.0.0.0", r_sdp) || switch_stristr("inactive", r_sdp)) {
hold_related = 1;
} }
if (!is_t38 && sofia_test_pflag(profile, PFLAG_PROXY_HOLD)) { if (!is_t38 && hold_related && switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) { if (switch_core_session_compare(session, other_session)) {
if (switch_stristr("sendonly", r_sdp) || switch_stristr("0.0.0.0", r_sdp) || switch_stristr("inactive", r_sdp)) {
switch_core_session_message_t *msg; switch_core_session_message_t *msg;
const char *hold_msg = "hold"; const char *hold_msg = "hold";
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session); private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
if (sofia_test_pflag(profile, PFLAG_PROXY_HOLD)) {
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
if (tech_pvt->mparams.num_codecs){ if (tech_pvt->mparams.num_codecs){
match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_REQUEST); match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_REQUEST);
} }
@ -7712,8 +7716,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
goto done; goto done;
} }
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);
msg = switch_core_session_alloc(other_session, sizeof(*msg)); msg = switch_core_session_alloc(other_session, sizeof(*msg));
if (switch_stristr("inactive", r_sdp)) { if (switch_stristr("inactive", r_sdp)) {
@ -7723,9 +7725,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sofia_clear_flag_locked(other_tech_pvt, TFLAG_SIP_HOLD_INACTIVE); sofia_clear_flag_locked(other_tech_pvt, TFLAG_SIP_HOLD_INACTIVE);
} }
if (hold_related == 1) {
msg->message_id = SWITCH_MESSAGE_INDICATE_HOLD; msg->message_id = SWITCH_MESSAGE_INDICATE_HOLD;
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
const char *info = switch_channel_get_variable(channel, "presence_call_info"); const char *info = switch_channel_get_variable(channel, "presence_call_info");
@ -7735,7 +7736,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
} }
} }
} }
sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD); sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_set_flag(channel, CF_LEG_HOLDING); switch_channel_set_flag(channel, CF_LEG_HOLDING);
switch_channel_presence(tech_pvt->channel, "unknown", hold_msg, NULL); switch_channel_presence(tech_pvt->channel, "unknown", hold_msg, NULL);
@ -7746,16 +7746,14 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_channel_clear_flag(channel, CF_LEG_HOLDING); switch_channel_clear_flag(channel, CF_LEG_HOLDING);
switch_channel_presence(tech_pvt->channel, "unknown", hold_msg, NULL); switch_channel_presence(tech_pvt->channel, "unknown", hold_msg, NULL);
} }
msg->from = __FILE__; msg->from = __FILE__;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Indicating %s to other leg.\n%s\n", hold_msg, r_sdp); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Indicating %s to other leg.\n%s\n", hold_msg, r_sdp);
switch_core_session_queue_message(other_session, msg); switch_core_session_queue_message(other_session, msg);
}
switch_core_session_rwunlock(other_session);
}
switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0); switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0);
if (sofia_use_soa(tech_pvt)){ if (sofia_use_soa(tech_pvt)){
nua_respond(tech_pvt->nh, SIP_200_OK, nua_respond(tech_pvt->nh, SIP_200_OK,
SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
@ -7771,6 +7769,15 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
} }
goto done; goto done;
} }
}
switch_core_session_rwunlock(other_session);
}
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_NEGOTIATED)) {
nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
goto done;
}
switch_channel_set_flag(tech_pvt->channel, CF_REINVITE); switch_channel_set_flag(tech_pvt->channel, CF_REINVITE);