From e90ccb151e336e50a7083bd5e6d35e82128151a9 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 31 Aug 2010 19:05:37 -0400 Subject: [PATCH] fix for segfaults in cases where we were still using raw_data as pointer --- libs/freetdm/mod_freetdm/mod_freetdm.c | 6 +++--- libs/freetdm/src/ftdm_io.c | 11 +++++++---- .../src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 5 +++-- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 890d9d9d43..50eb7a2c4d 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -2107,10 +2107,10 @@ static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal) } break; case FTDM_SIGEVENT_SIGSTATUS_CHANGED: - { - ftdm_signaling_status_t *sigstatus = (ftdm_signaling_status_t*)(sigmsg->raw_data); + { + ftdm_signaling_status_t sigstatus = sigmsg->raw_data ? *((ftdm_signaling_status_t*)(sigmsg->raw_data)) : sigmsg->sigstatus; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%d:%d signalling changed to :%s\n", - spanid, chanid, ftdm_signaling_status2str(*sigstatus)); + spanid, chanid, ftdm_signaling_status2str(sigstatus)); } break; default: diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index c53e9aa1fb..39eba67e8b 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -4410,10 +4410,13 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t switch (sigmsg->event_id) { case FTDM_SIGEVENT_SIGSTATUS_CHANGED: - if (*((ftdm_signaling_status_t*)(sigmsg->raw_data)) == FTDM_SIG_STATE_UP) { - ftdm_set_flag(sigmsg->channel, FTDM_CHANNEL_SIG_UP); - } else { - ftdm_clear_flag(sigmsg->channel, FTDM_CHANNEL_SIG_UP); + { + ftdm_signaling_status_t sigstatus = ftdm_test_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE) ? sigmsg->sigstatus : *((ftdm_signaling_status_t*)(sigmsg->raw_data)); + if (sigstatus == FTDM_SIG_STATE_UP) { + ftdm_set_flag(sigmsg->channel, FTDM_CHANNEL_SIG_UP); + } else { + ftdm_clear_flag(sigmsg->channel, FTDM_CHANNEL_SIG_UP); + } } break; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index b47660b076..12a98f979b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -279,11 +279,11 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) ftdm_channel_unlock(ftdmchan); } - /* Check if there are any timers to process */ while ((sngisdn_event = ftdm_queue_dequeue(signal_data->event_queue))) { ftdm_sangoma_isdn_process_stack_event(span, sngisdn_event); ftdm_safe_free(sngisdn_event); - } + } + ftdm_span_trigger_signals(span); break; case FTDM_TIMEOUT: /* twiddle */ @@ -791,6 +791,7 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) span->set_channel_sig_status = ftdm_sangoma_isdn_set_sig_status; span->state_map = &sangoma_isdn_state_map; ftdm_set_flag(span, FTDM_SPAN_USE_CHAN_QUEUE); + ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE); if (span->trunk_type == FTDM_TRUNK_BRI_PTMP || span->trunk_type == FTDM_TRUNK_BRI) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c index 5299c91b44..7aba6a66ce 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c @@ -48,7 +48,7 @@ void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status sig.span_id = ftdmchan->span_id; sig.channel = ftdmchan; sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; - sig.raw_data = &status; + sig.sigstatus = status; ftdm_span_send_signal(ftdmchan->span, &sig); return; }