From dd39a902e64ff908e87f6b54816c0f5fd1de4e0d Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Fri, 12 Mar 2010 19:25:44 +0000 Subject: [PATCH] fix double call to state_advance git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@1058 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/mod_freetdm/mod_freetdm.c | 1 + .../ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 800f5e23f6..468bcf10de 100644 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -746,6 +746,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc len = frame->datalen; if (ftdm_channel_write(tech_pvt->ftdmchan, frame->data, frame->buflen, &len) != FTDM_SUCCESS) { if (++tech_pvt->wr_error > 10) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "too many I/O write errors!\n"); goto fail; } } else { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c index 1f9e607490..e7317e3679 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c @@ -1229,7 +1229,7 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan) ftdm_sigmsg_t sig; ftdm_status_t status; - ftdm_log(FTDM_LOG_DEBUG, "%d:%d STATE [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, ftdm_channel_state2str(ftdmchan->state)); + ftdm_log(FTDM_LOG_DEBUG, "%d:%d PROCESSING STATE [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, ftdm_channel_state2str(ftdmchan->state)); memset(&sig, 0, sizeof(sig)); sig.chan_id = ftdmchan->chan_id; @@ -1470,10 +1470,15 @@ static __inline__ void check_state(ftdm_span_t *span) } } else { while ((ftdmchan = ftdm_queue_dequeue(span->pendingchans))) { + /* it can happen that someone else processed the chan states + * but without taking the chan out of the queue, so check th + * flag before advancing the state */ ftdm_mutex_lock(ftdmchan->mutex); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE); - state_advance(ftdmchan); - ftdm_channel_complete_state(ftdmchan); + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) { + ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE); + state_advance(ftdmchan); + ftdm_channel_complete_state(ftdmchan); + } ftdm_mutex_unlock(ftdmchan->mutex); } }