push out signal data into its own queue system

This commit is contained in:
Anthony Minessale 2011-07-08 12:52:12 -05:00
parent e420e17f84
commit f1ee225cb1
8 changed files with 80 additions and 15 deletions

View File

@ -145,6 +145,7 @@ struct switch_core_session {
void *private_info;
switch_queue_t *event_queue;
switch_queue_t *message_queue;
switch_queue_t *signal_data_queue;
switch_queue_t *private_event_queue;
switch_queue_t *private_event_queue_pri;
switch_thread_rwlock_t *bug_rwlock;

View File

@ -835,6 +835,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(_In_ switch_co
SWITCH_DECLARE(void) switch_core_session_free_message(switch_core_session_message_t **message);
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_signal_data(switch_core_session_t *session, void *signal_data);
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_signal_data(switch_core_session_t *session, void **signal_data);
/*!
\brief pass an indication message on a session
\param session the session to pass the message across

View File

@ -110,7 +110,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(_In_ switch_core_session_
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_next_event(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_messages(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_signal_data(switch_core_session_t *session);
/*!
\brief Wait for time to pass for a specified number of milliseconds
\param session the session to wait for.

View File

@ -316,7 +316,7 @@ typedef enum {
TFLAG_MAX
} TFLAGS;
#define SOFIA_MAX_MSG_QUEUE 25
#define SOFIA_MAX_MSG_QUEUE 250
#define SOFIA_MSG_QUEUE_SIZE 50
struct mod_sofia_globals {

View File

@ -1226,6 +1226,7 @@ void sofia_event_callback(nua_event_t event,
memset(de, 0, sizeof(*de));
nua_save_event(nua, de->event);
de->nh = nua_handle_ref(nh);
de->nh = nh;
de->data = nua_event_data(de->event);
de->sip = sip_object(de->data->e_msg);
de->profile = profile;
@ -1244,21 +1245,20 @@ void sofia_event_callback(nua_event_t event,
}
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) {
switch_core_session_message_t *msg;
switch_core_session_t *session;
if (!zstr(sofia_private->uuid)) {
if ((session = switch_core_session_locate(sofia_private->uuid))) {
msg = switch_core_session_alloc(session, sizeof(*msg));
msg->message_id = SWITCH_MESSAGE_INDICATE_SIGNAL_DATA;
msg->from = __FILE__;
msg->numeric_arg = status;
msg->pointer_arg = de;
if (switch_core_session_running(session)) {
switch_core_session_queue_message(session, msg);
switch_core_session_queue_signal_data(session, de);
} else {
switch_core_session_receive_message(session, msg);
switch_core_session_message_t msg = { 0 };
msg.message_id = SWITCH_MESSAGE_INDICATE_SIGNAL_DATA;
msg.from = __FILE__;
msg.pointer_arg = de;
switch_core_session_receive_message(session, &msg);
}
switch_core_session_rwunlock(session);
return;
@ -1266,6 +1266,7 @@ void sofia_event_callback(nua_event_t event,
}
}
sofia_queue_message(de);
}
@ -5017,7 +5018,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
NUTAG_ANSWER_SENT_REF(answer_sent),
SIPTAG_REPLACES_STR_REF(replaces_str), SOATAG_LOCAL_SDP_STR_REF(l_sdp), SOATAG_REMOTE_SDP_STR_REF(r_sdp), TAG_END());
if (session) {
channel = switch_core_session_get_channel(session);
tech_pvt = switch_core_session_get_private(session);

View File

@ -1728,10 +1728,8 @@ SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_
ret++;
}
if (ret) {
if (!switch_channel_test_flag(channel, CF_LEG_HOLDING) && switch_core_session_in_thread(channel->session)) {
switch_ivr_parse_all_events(channel->session);
}
if (ret && switch_core_session_in_thread(channel->session)) {
switch_ivr_parse_all_signal_data(channel->session);
}
return ret;

View File

@ -841,6 +841,42 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_flush_message(switch_core_se
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_queue_signal_data(switch_core_session_t *session, void *signal_data)
{
switch_status_t status = SWITCH_STATUS_FALSE;
switch_assert(session != NULL);
if (session->signal_data_queue) {
if (switch_queue_trypush(session->signal_data_queue, signal_data) == SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_SUCCESS;
}
switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_test_flag(session->channel, CF_THREAD_SLEEPING)) {
switch_core_session_wake_session_thread(session);
}
}
return status;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_signal_data(switch_core_session_t *session, void **signal_data)
{
switch_status_t status = SWITCH_STATUS_FALSE;
void *pop;
switch_assert(session != NULL);
if (session->signal_data_queue && switch_queue_size(session->signal_data_queue)) {
if ((status = (switch_status_t) switch_queue_trypop(session->signal_data_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
*signal_data = pop;
}
}
return status;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event)
{
@ -1713,6 +1749,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_
switch_thread_rwlock_create(&session->rwlock, session->pool);
switch_thread_rwlock_create(&session->io_rwlock, session->pool);
switch_queue_create(&session->message_queue, SWITCH_MESSAGE_QUEUE_LEN, session->pool);
switch_queue_create(&session->signal_data_queue, SWITCH_MESSAGE_QUEUE_LEN, session->pool);
switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
switch_queue_create(&session->private_event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
switch_queue_create(&session->private_event_queue_pri, SWITCH_EVENT_QUEUE_LEN, session->pool);

View File

@ -674,6 +674,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_messages(switch_core_sessio
switch_channel_t *channel = switch_core_session_get_channel(session);
int i = 0;
switch_ivr_parse_all_signal_data(session);
while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
i++;
@ -708,6 +710,29 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_messages(switch_core_sessio
return i ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_signal_data(switch_core_session_t *session)
{
void *data;
switch_core_session_message_t msg = { 0 };
int i = 0;
msg.message_id = SWITCH_MESSAGE_INDICATE_SIGNAL_DATA;
msg.from = __FILE__;
while (switch_core_session_dequeue_signal_data(session, &data) == SWITCH_STATUS_SUCCESS) {
i++;
msg.pointer_arg = data;
switch_core_session_receive_message(session, &msg);
data = NULL;
}
return i ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
{
int x = 0;