freetdm: hangup the chan call when the core fails to create the session

This commit is contained in:
Moises Silva 2010-04-23 16:28:01 -04:00 committed by Moises Silva
parent 554e433322
commit 56db486189
7 changed files with 45 additions and 24 deletions

View File

@ -1349,7 +1349,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
fail:
if (ftdmchan) {
ftdm_channel_done(ftdmchan);
ftdm_channel_call_hangup_with_cause(ftdmchan, FTDM_CAUSE_SWITCH_CONGESTION);
}
return cause;

View File

@ -1428,8 +1428,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direc
ftdm_span_channel_use_count(span, &count);
if (count >= span->chan_count) {
ftdm_log(FTDM_LOG_CRIT, "All circuits are busy: active=%i max=%i.\n",
count, span->chan_count);
ftdm_log(FTDM_LOG_ERROR, "All circuits are busy: active=%i max=%i.\n", count, span->chan_count);
*ftdmchan = NULL;
return FTDM_FAIL;
}
@ -1808,16 +1807,36 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_call_answer(ftdm_channel_t *ftdmchan)
return FTDM_SUCCESS;
}
static ftdm_status_t call_hangup(ftdm_channel_t *chan)
{
if (chan->state != FTDM_CHANNEL_STATE_DOWN) {
ftdm_set_state_wait(chan, FTDM_CHANNEL_STATE_HANGUP);
} else {
/* the signaling stack did not touch the state,
* core is responsible from clearing flags and stuff */
ftdm_channel_done(chan);
}
return FTDM_SUCCESS;
}
FT_DECLARE(ftdm_status_t) ftdm_channel_call_hangup_with_cause(ftdm_channel_t *ftdmchan, ftdm_call_cause_t cause)
{
ftdm_channel_lock(ftdmchan);
ftdmchan->caller_data.hangup_cause = cause;
ftdm_set_state_locked_wait(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
call_hangup(ftdmchan);
ftdm_channel_unlock(ftdmchan);
return FTDM_SUCCESS;
}
FT_DECLARE(ftdm_status_t) ftdm_channel_call_hangup(ftdm_channel_t *ftdmchan)
{
ftdm_set_state_locked_wait(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
ftdm_channel_lock(ftdmchan);
call_hangup(ftdmchan);
ftdm_channel_unlock(ftdmchan);
return FTDM_SUCCESS;
}

View File

@ -69,9 +69,6 @@ static ftdm_status_t ftdm_sangoma_boost_list_sigmods(ftdm_stream_handle_t *strea
#define BOOST_SPAN(ftdmchan) ((ftdm_sangoma_boost_data_t*)(ftdmchan)->span->signal_data)->sigmod ? ftdmchan->physical_span_id : ftdmchan->physical_span_id-1
#define BOOST_CHAN(ftdmchan) ((ftdm_sangoma_boost_data_t*)(ftdmchan)->span->signal_data)->sigmod ? ftdmchan->physical_chan_id : ftdmchan->physical_chan_id-1
#define BOOST_EVENT_SPAN(sigmod, event) ((sigmod)? event->span:event->span+1)
#define BOOST_EVENT_CHAN(sigmod, event) ((sigmod)? event->chan:event->chan+1)
/**
* \brief SANGOMA boost notification flag
*/
@ -957,7 +954,8 @@ static void handle_call_answer(ftdm_span_t *span, sangomabc_connection_t *mcon,
/* NC: Do nothing here because we are in process
of stopping the call. So ignore the ANSWER. */
ftdm_log(FTDM_LOG_CRIT, "ANSWER BUT CALL IS HANGUP %d:%d\n", event->span+1,event->chan+1);
ftdm_log(FTDM_LOG_DEBUG, "ANSWER BUT CALL IS HANGUP %d:%d\n", BOOST_EVENT_SPAN(mcon->sigmod, event),
BOOST_EVENT_CHAN(mcon->sigmod, event));
} else if (ftdmchan->state == FTDM_CHANNEL_STATE_HOLD) {
ftdmchan->init_state = FTDM_CHANNEL_STATE_UP;
@ -968,7 +966,7 @@ static void handle_call_answer(ftdm_span_t *span, sangomabc_connection_t *mcon,
}
ftdm_mutex_unlock(ftdmchan->mutex);
} else {
ftdm_log(FTDM_LOG_CRIT, "ANSWER CANT FIND A CHAN %d:%d\n", BOOST_EVENT_SPAN(mcon, event), BOOST_EVENT_CHAN(mcon, event));
ftdm_log(FTDM_LOG_CRIT, "ANSWER CANT FIND A CHAN %d:%d\n", BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
sangomabc_exec_command(mcon,
event->span,
event->chan,
@ -1924,7 +1922,7 @@ static void ftdm_cli_span_state_cmd(ftdm_span_t *span, char *state)
int cnt=0;
ftdm_channel_state_t state_e = ftdm_str2ftdm_channel_state(state);
if (state_e == FTDM_CHANNEL_STATE_INVALID) {
ftdm_log(FTDM_LOG_CRIT, "Checking for channels not in the INVALID state is probably not waht you want\n");
ftdm_log(FTDM_LOG_CRIT, "Checking for channels not in the INVALID state is probably not what you want\n");
}
for(j = 1; j <= span->chan_count; j++) {
if (span->channels[j]->state != state_e) {
@ -2187,7 +2185,7 @@ static ftdm_state_map_t boost_state_map = {
ZSM_UNACCEPTABLE,
{FTDM_CHANNEL_STATE_HOLD, FTDM_END},
{FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_PROGRESS,
FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_END}
FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_HANGUP, FTDM_END}
},
{
ZSD_OUTBOUND,

View File

@ -82,8 +82,8 @@ static void sangomabc_print_event_call(sangomabc_connection_t *mcon, sangomabc_e
priority ? "P":"N",
sangomabc_event_id_name(event->event_id),
event->event_id,
event->span,
event->chan,
BOOST_EVENT_SPAN(mcon->sigmod, event),
BOOST_EVENT_CHAN(mcon->sigmod, event),
event->call_setup_id,
event->fseqno,
strlen(event->calling_name)?event->calling_name:"N/A",
@ -101,8 +101,8 @@ static void sangomabc_print_event_short(sangomabc_connection_t *mcon, sangomabc_
priority ? "P":"N",
sangomabc_event_id_name(event->event_id),
event->event_id,
event->span,
event->chan,
BOOST_EVENT_SPAN(mcon->sigmod, event),
BOOST_EVENT_CHAN(mcon->sigmod, event),
event->release_cause,
event->call_setup_id,
event->fseqno);

View File

@ -144,6 +144,10 @@ const char *sangomabc_event_id_name(uint32_t event_id);
int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int id, int cmd, int cause, int flags);
int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, int id, int cmd, int cause);
#define BOOST_EVENT_SPAN(sigmod, event) ((sigmod)? event->span:event->span+1)
#define BOOST_EVENT_CHAN(sigmod, event) ((sigmod)? event->chan:event->chan+1)
#endif

View File

@ -634,7 +634,6 @@ FT_DECLARE(ftdm_status_t) ftdm_conf_node_create(const char *name, ftdm_conf_node
FT_DECLARE(ftdm_status_t) ftdm_conf_node_add_param(ftdm_conf_node_t *node, const char *param, const char *val);
FT_DECLARE(ftdm_status_t) ftdm_conf_node_destroy(ftdm_conf_node_t *node);
FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const char *str, ftdm_channel_config_t *chan_config, unsigned *configured);
FT_DECLARE(ftdm_status_t) ftdm_channel_done(ftdm_channel_t *ftdmchan);
FT_DECLARE(ftdm_channel_t *) ftdm_span_get_channel(const ftdm_span_t *span, uint32_t chanid);
FT_DECLARE(uint32_t) ftdm_span_get_chan_count(const ftdm_span_t *span);

View File

@ -559,6 +559,7 @@ FT_DECLARE(char *) ftdm_build_dso_path(const char *name, char *path, ftdm_size_t
FT_DECLARE(int) ftdm_load_module(const char *name);
FT_DECLARE(int) ftdm_load_module_assume(const char *name);
FT_DECLARE(int) ftdm_vasprintf(char **ret, const char *fmt, va_list ap);
FT_DECLARE(ftdm_status_t) ftdm_channel_done(ftdm_channel_t *ftdmchan);
FIO_CODEC_FUNCTION(fio_slin2ulaw);
FIO_CODEC_FUNCTION(fio_ulaw2slin);