mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 20:51:58 +00:00
[core, mod_sofia] Fix codec set deadlock
This commit is contained in:
@@ -1339,6 +1339,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
if (msg->message_id == SWITCH_MESSAGE_INDICATE_SIGNAL_DATA) {
|
||||
sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) msg->pointer_arg;
|
||||
|
||||
switch_core_session_lock_codec_write(session);
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
if (switch_core_session_in_thread(session)) {
|
||||
de->session = session;
|
||||
@@ -1346,8 +1348,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
sofia_process_dispatch_event(&de);
|
||||
|
||||
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
switch_core_session_unlock_codec_write(session);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1363,6 +1365,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
/* ones that do not need to lock sofia mutex */
|
||||
switch (msg->message_id) {
|
||||
case SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY:
|
||||
case SWITCH_MESSAGE_RESAMPLE_EVENT:
|
||||
goto end;
|
||||
case SWITCH_MESSAGE_INDICATE_KEEPALIVE:
|
||||
{
|
||||
if (msg->numeric_arg) {
|
||||
@@ -1523,6 +1528,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
|
||||
/* ones that do need to lock sofia mutex */
|
||||
switch_core_session_lock_codec_write(session);
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
if (switch_channel_down(channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
@@ -1557,7 +1563,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
tech_pvt->proxy_refer_uuid = (char *)msg->string_array_arg[0];
|
||||
} else if (!switch_channel_var_true(tech_pvt->channel, "sip_refer_continue_after_reply")) {
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
switch_core_session_unlock_codec_write(session);
|
||||
sofia_wait_for_reply(tech_pvt, 9999, 10);
|
||||
switch_core_session_lock_codec_write(session);
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
if ((var = switch_channel_get_variable(tech_pvt->channel, "sip_refer_reply"))) {
|
||||
@@ -2391,6 +2399,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
/* Unlock the session signal to allow the ack to make it in */
|
||||
// Maybe we should timeout?
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
switch_core_session_unlock_codec_write(session);
|
||||
|
||||
while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
|
||||
switch_ivr_parse_all_events(session);
|
||||
@@ -2398,6 +2407,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
|
||||
/* Regain lock on sofia */
|
||||
switch_core_session_lock_codec_write(session);
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
|
||||
@@ -2706,6 +2716,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
//}
|
||||
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
switch_core_session_unlock_codec_write(session);
|
||||
|
||||
end:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user