提交 d00a0fad authored 作者: Anthony Minessale's avatar Anthony Minessale

fix rtp break on blocking sockets

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7829 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 875c0851
...@@ -191,6 +191,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s ...@@ -191,6 +191,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
*/ */
SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session); SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session);
SWITCH_DECLARE(void) switch_rtp_break(switch_rtp_t *rtp_session);
/*! /*!
\brief Test if an RTP session is ready \brief Test if an RTP session is ready
\param rtp_session an RTP session to test \param rtp_session an RTP session to test
......
...@@ -644,10 +644,10 @@ static switch_status_t sofia_kill_channel(switch_core_session_t *session, int si ...@@ -644,10 +644,10 @@ static switch_status_t sofia_kill_channel(switch_core_session_t *session, int si
switch (sig) { switch (sig) {
case SWITCH_SIG_BREAK: case SWITCH_SIG_BREAK:
if (switch_rtp_ready(tech_pvt->rtp_session)) { if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_BREAK); switch_rtp_break(tech_pvt->rtp_session);
} }
if (switch_rtp_ready(tech_pvt->video_rtp_session)) { if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
switch_rtp_set_flag(tech_pvt->video_rtp_session, SWITCH_RTP_FLAG_BREAK); switch_rtp_break(tech_pvt->rtp_session);
} }
break; break;
case SWITCH_SIG_KILL: case SWITCH_SIG_KILL:
......
...@@ -1436,7 +1436,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status ...@@ -1436,7 +1436,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
} }
if (switch_core_session_receive_message(other_session, &msg) != SWITCH_STATUS_SUCCESS) { if (switch_core_session_receive_message(other_session, &msg) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Other leg is not available\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Other leg is not available\n");
nua_respond(tech_pvt->nh, 488, "Hangup in progress", TAG_END()); nua_respond(tech_pvt->nh, 403, "Hangup in progress", TAG_END());
} }
switch_core_session_rwunlock(other_session); switch_core_session_rwunlock(other_session);
} }
...@@ -1780,7 +1780,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, ...@@ -1780,7 +1780,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Passing SDP to other leg.\n%s\n", r_sdp); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Passing SDP to other leg.\n%s\n", r_sdp);
if (switch_core_session_receive_message(other_session, &msg) != SWITCH_STATUS_SUCCESS) { if (switch_core_session_receive_message(other_session, &msg) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Other leg is not available\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Other leg is not available\n");
nua_respond(tech_pvt->nh, 488, "Hangup in progress", TAG_END()); nua_respond(tech_pvt->nh, 403, "Hangup in progress", TAG_END());
} }
switch_core_session_rwunlock(other_session); switch_core_session_rwunlock(other_session);
} else { } else {
......
...@@ -804,14 +804,29 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio ...@@ -804,14 +804,29 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_DECLARE(void) switch_rtp_break(switch_rtp_t *rtp_session)
{
char o = 42;
switch_size_t len = sizeof(o);
switch_assert(rtp_session != NULL);
switch_mutex_lock(rtp_session->flag_mutex);
if (rtp_session->sock) {
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
switch_socket_sendto(rtp_session->sock, rtp_session->local_addr, 0, (void *) &o, &len);
}
switch_mutex_unlock(rtp_session->flag_mutex);
}
SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session) SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session)
{ {
switch_assert(rtp_session != NULL); switch_assert(rtp_session != NULL);
switch_mutex_lock(rtp_session->flag_mutex); switch_mutex_lock(rtp_session->flag_mutex);
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) { if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) {
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO); switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO);
switch_assert(rtp_session->sock != NULL); if (rtp_session->sock) {
switch_socket_shutdown(rtp_session->sock, SWITCH_SHUTDOWN_READWRITE); switch_socket_shutdown(rtp_session->sock, SWITCH_SHUTDOWN_READWRITE);
}
} }
switch_mutex_unlock(rtp_session->flag_mutex); switch_mutex_unlock(rtp_session->flag_mutex);
} }
...@@ -1081,6 +1096,13 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ ...@@ -1081,6 +1096,13 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
bytes = sizeof(rtp_msg_t); bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes); status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes);
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) {
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
bytes = 0;
do_cng = 1;
goto cng;
}
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
/* Fast PASS! */ /* Fast PASS! */
*flags |= SFF_PROXY_PACKET; *flags |= SFF_PROXY_PACKET;
...@@ -1224,10 +1246,9 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ ...@@ -1224,10 +1246,9 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
do_cng = 1; do_cng = 1;
} }
if (do_cng || (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK))) {
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
cng:
if (do_cng) {
memset(&rtp_session->recv_msg.body, 0, 2); memset(&rtp_session->recv_msg.body, 0, 2);
rtp_session->recv_msg.body[0] = 127; rtp_session->recv_msg.body[0] = 127;
rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD; rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论