freetdm: core - changed behavior of ftdm_channel_close(). instead of returning if the channel isn't
opened, not it prints a warning and proceeds to close it. ftmod_r2 - added handler for FTDM_CHANNEL_STATE_RESET state
This commit is contained in:
parent
656ecc1bc0
commit
fa5ec0e553
|
@ -2726,14 +2726,13 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_close(ftdm_channel_t **ftdmchan)
|
||||||
|
|
||||||
if (ftdm_test_flag(check, FTDM_CHANNEL_CONFIGURED)) {
|
if (ftdm_test_flag(check, FTDM_CHANNEL_CONFIGURED)) {
|
||||||
ftdm_mutex_lock(check->mutex);
|
ftdm_mutex_lock(check->mutex);
|
||||||
if (ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) {
|
if (!ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) {
|
||||||
status = check->fio->close(check);
|
ftdm_log_chan_msg(check, FTDM_LOG_WARNING, "Channel not opened, proceeding anyway\n");
|
||||||
if (status == FTDM_SUCCESS) {
|
}
|
||||||
ftdm_channel_done(check);
|
status = check->fio->close(check);
|
||||||
*ftdmchan = NULL;
|
if (status == FTDM_SUCCESS) {
|
||||||
}
|
ftdm_channel_done(check);
|
||||||
} else {
|
*ftdmchan = NULL;
|
||||||
ftdm_log_chan_msg(check, FTDM_LOG_WARNING, "Called ftdm_channel_close but never ftdm_channel_open??\n");
|
|
||||||
}
|
}
|
||||||
check->ring_count = 0;
|
check->ring_count = 0;
|
||||||
ftdm_mutex_unlock(check->mutex);
|
ftdm_mutex_unlock(check->mutex);
|
||||||
|
|
|
@ -1234,6 +1234,18 @@ static openr2_log_level_t ftdm_r2_loglevel_from_string(const char *level)
|
||||||
|
|
||||||
static ftdm_state_map_t r2_state_map = {
|
static ftdm_state_map_t r2_state_map = {
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
ZSD_INBOUND,
|
||||||
|
ZSM_UNACCEPTABLE,
|
||||||
|
{FTDM_ANY_STATE, FTDM_END},
|
||||||
|
{FTDM_CHANNEL_STATE_RESET, FTDM_END}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ZSD_INBOUND,
|
||||||
|
ZSM_UNACCEPTABLE,
|
||||||
|
{FTDM_CHANNEL_STATE_RESET, FTDM_END},
|
||||||
|
{FTDM_CHANNEL_STATE_DOWN, FTDM_END}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ZSD_INBOUND,
|
ZSD_INBOUND,
|
||||||
ZSM_UNACCEPTABLE,
|
ZSM_UNACCEPTABLE,
|
||||||
|
@ -1285,6 +1297,20 @@ static ftdm_state_map_t r2_state_map = {
|
||||||
|
|
||||||
/* Outbound states */
|
/* Outbound states */
|
||||||
|
|
||||||
|
{
|
||||||
|
ZSD_OUTBOUND,
|
||||||
|
ZSM_UNACCEPTABLE,
|
||||||
|
{FTDM_ANY_STATE, FTDM_END},
|
||||||
|
{FTDM_CHANNEL_STATE_RESET, FTDM_END}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
ZSD_OUTBOUND,
|
||||||
|
ZSM_UNACCEPTABLE,
|
||||||
|
{FTDM_CHANNEL_STATE_RESET, FTDM_END},
|
||||||
|
{FTDM_CHANNEL_STATE_DOWN, FTDM_END}
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
ZSD_OUTBOUND,
|
ZSD_OUTBOUND,
|
||||||
ZSM_UNACCEPTABLE,
|
ZSM_UNACCEPTABLE,
|
||||||
|
@ -1774,7 +1800,9 @@ static int ftdm_r2_state_advance(ftdm_channel_t *ftdmchan)
|
||||||
/* finished call for good */
|
/* finished call for good */
|
||||||
case FTDM_CHANNEL_STATE_DOWN:
|
case FTDM_CHANNEL_STATE_DOWN:
|
||||||
{
|
{
|
||||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "R2 Call is down\n");
|
if (ftdmchan->last_state != FTDM_CHANNEL_STATE_RESET) {
|
||||||
|
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "R2 Call is down\n");
|
||||||
|
}
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1786,6 +1814,15 @@ static int ftdm_r2_state_advance(ftdm_channel_t *ftdmchan)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* put the r2 channel back to IDLE, close ftdmchan and set it's state as DOWN */
|
||||||
|
case FTDM_CHANNEL_STATE_RESET:
|
||||||
|
{
|
||||||
|
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "RESET indicated, putting the R2 channel back to IDLE\n");
|
||||||
|
openr2_chan_set_idle(r2chan);
|
||||||
|
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Unhandled channel state change: %s\n", ftdm_channel_state2str(ftdmchan->state));
|
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Unhandled channel state change: %s\n", ftdm_channel_state2str(ftdmchan->state));
|
||||||
|
|
Loading…
Reference in New Issue