git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7745 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-02-26 20:31:53 +00:00
parent 1bf92980a7
commit e697bf8d26
4 changed files with 35 additions and 28 deletions

View File

@ -707,8 +707,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
private_object_t *tech_pvt = switch_core_session_get_private(session); private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_mutex_lock(tech_pvt->flag_mutex);
if (switch_channel_get_state(channel) >= CS_HANGUP || !tech_pvt) { if (switch_channel_get_state(channel) >= CS_HANGUP || !tech_pvt) {
status = SWITCH_STATUS_FALSE; status = SWITCH_STATUS_FALSE;
goto end; goto end;
@ -717,7 +715,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) { if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) {
const char *var; const char *var;
if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) { if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) {
switch_set_flag(tech_pvt, TFLAG_SECURE); switch_set_flag_locked(tech_pvt, TFLAG_SECURE);
} }
} }
@ -789,7 +787,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending media re-direct:\n%s\n", msg->string_arg); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending media re-direct:\n%s\n", msg->string_arg);
tech_pvt->local_sdp_str = switch_core_session_strdup(session, msg->string_arg); tech_pvt->local_sdp_str = switch_core_session_strdup(session, msg->string_arg);
switch_set_flag(tech_pvt, TFLAG_SENT_UPDATE); switch_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
sofia_glue_do_invite(session); sofia_glue_do_invite(session);
} }
break; break;
@ -828,7 +826,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
case SWITCH_MESSAGE_INDICATE_HOLD: case SWITCH_MESSAGE_INDICATE_HOLD:
{ {
switch_set_flag(tech_pvt, TFLAG_SIP_HOLD); switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
sofia_glue_do_invite(session); sofia_glue_do_invite(session);
} }
break; break;
@ -850,7 +848,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
private_object_t *a_tech_pvt = switch_core_session_get_private(a_session); private_object_t *a_tech_pvt = switch_core_session_get_private(a_session);
private_object_t *b_tech_pvt = switch_core_session_get_private(b_session); private_object_t *b_tech_pvt = switch_core_session_get_private(b_session);
switch_set_flag(a_tech_pvt, TFLAG_REINVITE); switch_set_flag_locked(a_tech_pvt, TFLAG_REINVITE);
a_tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(a_session, b_tech_pvt->remote_sdp_audio_ip); a_tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(a_session, b_tech_pvt->remote_sdp_audio_ip);
a_tech_pvt->remote_sdp_audio_port = b_tech_pvt->remote_sdp_audio_port; a_tech_pvt->remote_sdp_audio_port = b_tech_pvt->remote_sdp_audio_port;
a_tech_pvt->local_sdp_audio_ip = switch_core_session_strdup(a_session, b_tech_pvt->local_sdp_audio_ip); a_tech_pvt->local_sdp_audio_ip = switch_core_session_strdup(a_session, b_tech_pvt->local_sdp_audio_ip);
@ -886,7 +884,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (msg->string_arg) { if (msg->string_arg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-directing to %s\n", msg->string_arg); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-directing to %s\n", msg->string_arg);
nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END()); nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END());
switch_set_flag(tech_pvt, TFLAG_BYE); switch_set_flag_locked(tech_pvt, TFLAG_BYE);
} }
break; break;
@ -963,7 +961,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
nua_respond(tech_pvt->nh, code, reason, TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)), nua_respond(tech_pvt->nh, code, reason, TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)),
SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL), SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL),
TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END()); TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END());
switch_set_flag(tech_pvt, TFLAG_BYE); switch_set_flag_locked(tech_pvt, TFLAG_BYE);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding with %d %s\n", code, reason); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding with %d %s\n", code, reason);
@ -981,7 +979,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
} else { } else {
nua_respond(tech_pvt->nh, code, reason, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END()); nua_respond(tech_pvt->nh, code, reason, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END());
} }
switch_set_flag(tech_pvt, TFLAG_BYE); switch_set_flag_locked(tech_pvt, TFLAG_BYE);
} }
} }
@ -1000,7 +998,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
{ {
if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) { if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
switch_set_flag(tech_pvt, TFLAG_EARLY_MEDIA); switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
/* Transmit 183 Progress with SDP */ /* Transmit 183 Progress with SDP */
@ -1061,10 +1059,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
end: end:
//xxxbot
switch_mutex_unlock(tech_pvt->flag_mutex);
return status; return status;
} }

View File

@ -1425,7 +1425,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
switch_assert(tech_pvt != NULL); switch_assert(tech_pvt != NULL);
switch_mutex_lock(tech_pvt->flag_mutex); switch_core_session_signal_lock(tech_pvt->session);
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE)) { if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE)) {
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
@ -1665,7 +1665,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
end: end:
switch_mutex_unlock(tech_pvt->flag_mutex); switch_core_session_signal_unlock(tech_pvt->session);
return status; return status;
} }

View File

@ -343,11 +343,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_
switch_assert(session != NULL); switch_assert(session != NULL);
if (switch_channel_get_state(session->channel) >= CS_HANGUP) {
return SWITCH_STATUS_FALSE;
}
if ((status = switch_core_session_read_lock(session)) != SWITCH_STATUS_SUCCESS) { if ((status = switch_core_session_read_lock(session)) != SWITCH_STATUS_SUCCESS) {
return status; return status;
} }
switch_core_session_signal_lock(session); switch_core_session_signal_lock(session);
if (session->endpoint_interface->io_routines->receive_message) { if (session->endpoint_interface->io_routines->receive_message) {

View File

@ -414,6 +414,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
break; break;
case CS_DONE: case CS_DONE:
goto done; goto done;
/* HANGUP INIT RING and RESET are all short term so we signal lock during their callbacks */
case CS_HANGUP: /* Deactivate and end the thread */ case CS_HANGUP: /* Deactivate and end the thread */
{ {
const char *var = switch_channel_get_variable(session->channel, SWITCH_PROCESS_CDR_VARIABLE); const char *var = switch_channel_get_variable(session->channel, SWITCH_PROCESS_CDR_VARIABLE);
@ -431,35 +432,43 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
do_extra_handlers = 0; do_extra_handlers = 0;
} }
} }
switch_core_session_signal_lock(session);
STATE_MACRO(hangup, "HANGUP"); STATE_MACRO(hangup, "HANGUP");
switch_core_session_signal_unlock(session);
} }
goto done; goto done;
case CS_INIT: /* Basic setup tasks */ case CS_INIT: /* Basic setup tasks */
switch_core_session_signal_lock(session);
STATE_MACRO(init, "INIT"); STATE_MACRO(init, "INIT");
switch_core_session_signal_unlock(session);
break; break;
case CS_RING: /* Look for a dialplan and find something to do */ case CS_RING: /* Look for a dialplan and find something to do */
switch_core_session_signal_lock(session);
STATE_MACRO(ring, "RING"); STATE_MACRO(ring, "RING");
switch_core_session_signal_unlock(session);
break; break;
case CS_RESET: /* Reset */ case CS_RESET: /* Reset */
switch_core_session_signal_lock(session);
STATE_MACRO(reset, "RESET"); STATE_MACRO(reset, "RESET");
switch_core_session_signal_unlock(session);
break; break;
case CS_EXECUTE: /* Execute an Operation */ /* These other states are intended for prolonged durations so we do not signal lock for them */
case CS_EXECUTE: /* Execute an Operation */
STATE_MACRO(execute, "EXECUTE"); STATE_MACRO(execute, "EXECUTE");
break; break;
case CS_LOOPBACK: /* loop all data back to source */ case CS_LOOPBACK: /* loop all data back to source */
STATE_MACRO(loopback, "LOOPBACK"); STATE_MACRO(loopback, "LOOPBACK");
break; break;
case CS_TRANSMIT: /* send/recieve data to/from another channel */ case CS_TRANSMIT: /* send/recieve data to/from another channel */
STATE_MACRO(transmit, "TRANSMIT"); STATE_MACRO(transmit, "TRANSMIT");
break; break;
case CS_PARK: /* wait in limbo */ case CS_PARK: /* wait in limbo */
STATE_MACRO(park, "PARK"); STATE_MACRO(park, "PARK");
break; break;
case CS_HOLD: /* wait in limbo */ case CS_HOLD: /* wait in limbo */
STATE_MACRO(hold, "HOLD"); STATE_MACRO(hold, "HOLD");
break; break;
case CS_HIBERNATE: /* sleep */ case CS_HIBERNATE: /* sleep */
STATE_MACRO(hibernate, "HIBERNATE"); STATE_MACRO(hibernate, "HIBERNATE");
break; break;
case CS_NONE: case CS_NONE: