Skinny: correct early media and answer

- SWITCH_MESSAGE_INDICATE_DISPLAY was missing a "break" statement
- handle not responding device (cancels early media or answer)
- don't send messages when listener is not ready (fix rare crashes)
This commit is contained in:
Mathieu Parent 2010-06-25 01:05:43 +02:00
parent 4e82098307
commit 20194286a4
2 changed files with 33 additions and 23 deletions

View File

@ -957,10 +957,16 @@ switch_status_t channel_answer_channel(switch_core_session_t *session)
switch_channel_get_variable(channel, "skinny_device_name"), switch_channel_get_variable(channel, "skinny_device_name"),
atoi(switch_channel_get_variable(channel, "skinny_device_instance")), &listener); atoi(switch_channel_get_variable(channel, "skinny_device_instance")), &listener);
if (listener) { if (listener) {
int x = 0;
skinny_session_start_media(session, listener, atoi(switch_channel_get_variable(channel, "skinny_line_instance"))); skinny_session_start_media(session, listener, atoi(switch_channel_get_variable(channel, "skinny_line_instance")));
/* Wait for media */ /* Wait for media */
while(!switch_test_flag(tech_pvt, TFLAG_IO)) { while(!switch_test_flag(tech_pvt, TFLAG_IO)) {
switch_cond_next(); switch_cond_next();
if (++x > 1000) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Wait tooo long to answer %s:%s\n",
switch_channel_get_variable(channel, "skinny_device_name"), switch_channel_get_variable(channel, "skinny_device_instance"));
return SWITCH_STATUS_FALSE;
}
} }
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Unable to find listener to answer %s:%s\n", switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Unable to find listener to answer %s:%s\n",
@ -976,28 +982,26 @@ switch_status_t channel_receive_message(switch_core_session_t *session, switch_c
switch (msg->message_id) { switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_ANSWER: case SWITCH_MESSAGE_INDICATE_ANSWER:
{
switch_clear_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); switch_clear_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
channel_answer_channel(session); return channel_answer_channel(session);
}
break;
case SWITCH_MESSAGE_INDICATE_DISPLAY: case SWITCH_MESSAGE_INDICATE_DISPLAY:
{
skinny_session_send_call_info_all(session); skinny_session_send_call_info_all(session);
} return SWITCH_STATUS_SUCCESS;
case SWITCH_MESSAGE_INDICATE_PROGRESS: case SWITCH_MESSAGE_INDICATE_PROGRESS:
{
if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) { if (!switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
/* early media */ /* early media */
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
channel_answer_channel(session); return channel_answer_channel(session);
}
} }
return SWITCH_STATUS_SUCCESS;
default: default:
break; return SWITCH_STATUS_SUCCESS;
} }
return SWITCH_STATUS_SUCCESS;
} }
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines

View File

@ -914,13 +914,19 @@ switch_status_t skinny_perform_send_reply(listener_t *listener, const char *file
len = reply->length+8; len = reply->length+8;
ptr = (char *) reply; ptr = (char *) reply;
if (listener_is_ready(listener)) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG,
"Sending %s (type=%x,length=%d) to %s:%d.\n", "Sending %s (type=%x,length=%d) to %s:%d.\n",
skinny_message_type2str(reply->type), reply->type, reply->length, skinny_message_type2str(reply->type), reply->type, reply->length,
listener->device_name, listener->device_instance); listener->device_name, listener->device_instance);
switch_socket_send(listener->sock, ptr, &len); return switch_socket_send(listener->sock, ptr, &len);
} else {
return SWITCH_STATUS_SUCCESS; switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING,
"Not sending %s (type=%x,length=%d) to %s:%d while not ready.\n",
skinny_message_type2str(reply->type), reply->type, reply->length,
listener->device_name, listener->device_instance);
return SWITCH_STATUS_FALSE;
}
} }
/* For Emacs: /* For Emacs: