Use the pendingchans queue only on request by signaling modules.
Remove suggest_chan_id member and add a span flag instead.
This commit is contained in:
parent
b9d5c62b3d
commit
428931bce2
|
@ -412,7 +412,9 @@ static ftdm_status_t ftdm_span_destroy(ftdm_span_t *span)
|
|||
}
|
||||
|
||||
/* destroy final basic resources of the span data structure */
|
||||
if (span->pendingchans) {
|
||||
ftdm_queue_destroy(&span->pendingchans);
|
||||
}
|
||||
ftdm_mutex_unlock(span->mutex);
|
||||
ftdm_mutex_destroy(&span->mutex);
|
||||
ftdm_safe_free(span->signal_data);
|
||||
|
@ -518,9 +520,6 @@ FT_DECLARE(ftdm_status_t) ftdm_span_create(ftdm_io_interface_t *fio, ftdm_span_t
|
|||
status = ftdm_mutex_create(&new_span->mutex);
|
||||
ftdm_assert(status == FTDM_SUCCESS, "mutex creation failed\n");
|
||||
|
||||
status = ftdm_queue_create(&new_span->pendingchans, SPAN_PENDING_CHANS_QUEUE_SIZE);
|
||||
ftdm_assert(status == FTDM_SUCCESS, "span chans queue creation failed\n");
|
||||
|
||||
ftdm_set_flag(new_span, FTDM_SPAN_CONFIGURED);
|
||||
new_span->span_id = ++globals.span_index;
|
||||
new_span->fio = fio;
|
||||
|
@ -1163,7 +1162,9 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(ftdm_channel_t *ftdmchan, ftdm_
|
|||
|
||||
ftdm_mutex_lock(ftdmchan->span->mutex);
|
||||
ftdm_set_flag(ftdmchan->span, FTDM_SPAN_STATE_CHANGE);
|
||||
if (ftdmchan->span->pendingchans) {
|
||||
ftdm_queue_enqueue(ftdmchan->span->pendingchans, ftdmchan);
|
||||
}
|
||||
ftdm_mutex_unlock(ftdmchan->span->mutex);
|
||||
|
||||
ftdmchan->last_state = ftdmchan->state;
|
||||
|
@ -1329,7 +1330,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direc
|
|||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
if (span->channel_request && !span->suggest_chan_id) {
|
||||
if (span->channel_request && !ftdm_test_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID)) {
|
||||
ftdm_set_caller_data(span, caller_data);
|
||||
return span->channel_request(span, 0, direction, caller_data, ftdmchan);
|
||||
}
|
||||
|
@ -3266,6 +3267,9 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span(const char *type, ftdm_span_t *spa
|
|||
va_list ap;
|
||||
va_start(ap, sig_cb);
|
||||
status = mod->sig_configure(span, sig_cb, ap);
|
||||
if (status == FTDM_SUCCESS && ftdm_test_flag(span, FTDM_SPAN_USE_CHAN_QUEUE)) {
|
||||
status = ftdm_queue_create(&span->pendingchans, SPAN_PENDING_CHANS_QUEUE_SIZE);
|
||||
}
|
||||
va_end(ap);
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_ERROR, "can't find '%s'\n", type);
|
||||
|
|
|
@ -2385,7 +2385,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_isdn_configure_span)
|
|||
|
||||
if ((isdn_data->opts & FTDM_ISDN_OPT_SUGGEST_CHANNEL)) {
|
||||
span->channel_request = isdn_channel_request;
|
||||
span->suggest_chan_id = 1;
|
||||
ftdm_set_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID);
|
||||
}
|
||||
span->state_map = &isdn_state_map;
|
||||
|
||||
|
|
|
@ -1331,7 +1331,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_libpri_configure_span)
|
|||
|
||||
if ((isdn_data->opts & FTMOD_LIBPRI_OPT_SUGGEST_CHANNEL)) {
|
||||
span->channel_request = isdn_channel_request;
|
||||
span->suggest_chan_id = 1;
|
||||
ftdm_set_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID);
|
||||
}
|
||||
|
||||
span->state_map = &isdn_state_map;
|
||||
|
|
|
@ -2239,7 +2239,8 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_boost_configure_span)
|
|||
span->get_span_sig_status = sangoma_boost_get_span_sig_status;
|
||||
span->set_span_sig_status = sangoma_boost_set_span_sig_status;
|
||||
span->state_map = &boost_state_map;
|
||||
span->suggest_chan_id = 0;
|
||||
ftdm_clear_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID);
|
||||
ftdm_set_flag(span, FTDM_SPAN_USE_CHAN_QUEUE);
|
||||
if (sigmod_iface) {
|
||||
/* the core will do the hunting */
|
||||
span->channel_request = NULL;
|
||||
|
|
|
@ -654,7 +654,6 @@ struct ftdm_span {
|
|||
char *type;
|
||||
char *dtmf_hangup;
|
||||
size_t dtmf_hangup_len;
|
||||
int suggest_chan_id;
|
||||
ftdm_state_map_t *state_map;
|
||||
ftdm_caller_data_t default_caller_data;
|
||||
ftdm_queue_t *pendingchans;
|
||||
|
|
|
@ -325,7 +325,9 @@ typedef enum {
|
|||
FTDM_SPAN_STATE_CHANGE = (1 << 2),
|
||||
FTDM_SPAN_SUSPENDED = (1 << 3),
|
||||
FTDM_SPAN_IN_THREAD = (1 << 4),
|
||||
FTDM_SPAN_STOP_THREAD = (1 << 5)
|
||||
FTDM_SPAN_STOP_THREAD = (1 << 5),
|
||||
FTDM_SPAN_USE_CHAN_QUEUE = (1 << 6),
|
||||
FTDM_SPAN_SUGGEST_CHAN_ID = (1 << 7),
|
||||
} ftdm_span_flag_t;
|
||||
|
||||
typedef enum {
|
||||
|
|
Loading…
Reference in New Issue