freetdm: Add new queue for ss7 clone messages, all incoming messages are queued now

This commit is contained in:
Moises Silva 2012-01-26 15:21:51 -05:00
parent 28e27248e5
commit 1b964054de
3 changed files with 22 additions and 0 deletions

View File

@ -511,6 +511,7 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev
{
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *event_clone = NULL;
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(sngss7_event->circuit, &sngss7_info, &ftdmchan)) {
@ -521,6 +522,22 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev
/* now that we have the right channel ... put a lock on it so no-one else can use it */
ftdm_channel_lock(ftdmchan);
if (sngss7_info->event_queue) {
if (sngss7_event->event_id == SNGSS7_CON_IND_EVENT) {
/* this is the first event in a call, flush the event queue */
while ((event_clone = ftdm_queue_dequeue(sngss7_info->event_queue))) {
SS7_WARN("Discarding clone event from past call for circuit = %d!\n", sngss7_event->circuit);
ftdm_safe_free(event_clone);
}
}
/* clone the event and save it for later usage */
event_clone = ftdm_calloc(1, sizeof(*sngss7_event));
if (event_clone) {
memcpy(clone, sngss7_event, sizeof(*sngss7_event));
ftdm_queue_enqueue(sngss7_info->event_queue, clone);
}
}
/* while there's a state change present on this channel process it */
ftdm_channel_advance_states(ftdmchan);
@ -576,6 +593,7 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev
break;
/**************************************************************************/
case (SNGSS7_SSP_STA_CFM_EVENT):
SS7_ERROR("dazed and confused ... hu?!\n");
break;
/**************************************************************************/
default:

View File

@ -485,6 +485,7 @@ typedef struct sngss7_chan_data {
sngss7_group_data_t rx_gra;
sngss7_group_data_t tx_grs;
sngss7_group_data_t ucic;
ftdm_queue_t *event_queue;
} sngss7_chan_data_t;
#define SNGSS7_RX_GRS_PENDING (1 << 0)

View File

@ -2925,6 +2925,9 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)
/* prepare the global info sturcture */
ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t));
ss7_info->ftdmchan = NULL;
if (ftdm_queue_create(&ss7_info->event_queue, SNGSS7_EVENT_QUEUE_SIZE) != FTDM_SUCCESS) {
SS7_CRITICAL("Failed to create ss7 cic event queue\n");
}
ss7_info->circuit = &g_ftdm_sngss7_data.cfg.isupCkt[x];
g_ftdm_sngss7_data.cfg.isupCkt[x].obj = ss7_info;