fix double call to state_advance

git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@1058 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Moises Silva 2010-03-12 19:25:44 +00:00
parent 5305611be3
commit dd39a902e6
2 changed files with 10 additions and 4 deletions

View File

@ -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 {

View File

@ -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);
}
}