freetdm: wait for analog thread to be done before shutdown
add more debug logging fix signaling status return code in ftdm_io
This commit is contained in:
parent
95877d1e44
commit
9c8be17f3d
|
@ -3790,10 +3790,11 @@ FT_DECLARE(ftdm_status_t) ftdm_unload_modules(void)
|
|||
static ftdm_status_t post_configure_span_channels(ftdm_span_t *span)
|
||||
{
|
||||
unsigned i = 0;
|
||||
ftdm_signaling_status_t status = FTDM_SUCCESS;
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN;
|
||||
for (i = 1; i <= span->chan_count; i++) {
|
||||
ftdm_channel_get_sig_status(span->channels[i], &status);
|
||||
if (status == FTDM_SIG_STATE_UP) {
|
||||
ftdm_channel_get_sig_status(span->channels[i], &sigstatus);
|
||||
if (sigstatus == FTDM_SIG_STATE_UP) {
|
||||
ftdm_set_flag(span->channels[i], FTDM_CHANNEL_SIG_UP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,6 +122,27 @@ static ftdm_status_t ftdm_analog_start(ftdm_span_t *span)
|
|||
return ftdm_thread_create_detached(ftdm_analog_run, span);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Stops the analog span thread (monitor)
|
||||
* \param span Span to stop
|
||||
* \return Success or failure
|
||||
*/
|
||||
static ftdm_status_t ftdm_analog_stop(ftdm_span_t *span)
|
||||
{
|
||||
ftdm_analog_data_t *analog_data = span->signal_data;
|
||||
int32_t sanity = 100;
|
||||
while (ftdm_test_flag(analog_data, FTDM_ANALOG_RUNNING) && sanity--) {
|
||||
ftdm_sleep(100);
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Waiting for analog thread for span %s to stop\n", span->name);
|
||||
}
|
||||
|
||||
if (!sanity) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "The analog thread for span %s is probably still running, we may crash :(\n", span->name);
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Initialises an analog span from configuration variables
|
||||
* \param span Span to configure
|
||||
|
@ -142,8 +163,10 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span)
|
|||
uint32_t flags = FTDM_ANALOG_CALLERID;
|
||||
|
||||
assert(sig_cb != NULL);
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Configuring span %s for analog signaling ...\n", span->name);
|
||||
|
||||
if (span->signal_type) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Span %s is already configured for signaling %d\n", span->name, span->signal_type);
|
||||
snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling.");
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
@ -184,8 +207,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span)
|
|||
}
|
||||
hotline = val;
|
||||
} else {
|
||||
snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var);
|
||||
return FTDM_FAIL;
|
||||
ftdm_log(FTDM_LOG_ERROR, "Unknown parameter %s in span %s\n", var, span->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,6 +221,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span)
|
|||
}
|
||||
|
||||
span->start = ftdm_analog_start;
|
||||
span->stop = ftdm_analog_stop;
|
||||
analog_data->flags = flags;
|
||||
analog_data->digit_timeout = digit_timeout;
|
||||
analog_data->max_dialstr = max_dialstr;
|
||||
|
@ -212,6 +235,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span)
|
|||
|
||||
ftdm_span_load_tones(span, tonemap);
|
||||
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Configuration of analog signaling for span %s is done\n", span->name);
|
||||
return FTDM_SUCCESS;
|
||||
|
||||
}
|
||||
|
|
|
@ -987,6 +987,7 @@ ZIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
|
||||
sangoma_tdm_txsig_onhook(zchan->sockfd,&tdm_api);
|
||||
}
|
||||
zap_log(ZAP_LOG_DEBUG, "%d:%d Returning fake ONHOOK\n", span->channels[i]->span_id, span->channels[i]->chan_id);
|
||||
goto event;
|
||||
}
|
||||
}
|
||||
|
@ -1003,6 +1004,7 @@ ZIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
return ZAP_FAIL;
|
||||
}
|
||||
|
||||
zap_log(ZAP_LOG_DEBUG, "%d:%d wanpipe returned event %d\n", span->channels[i]->span_id, span->channels[i]->chan_id, tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type);
|
||||
switch(tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type) {
|
||||
|
||||
case WP_TDMAPI_EVENT_LINK_STATUS:
|
||||
|
@ -1027,6 +1029,8 @@ ZIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
|||
|
||||
case WP_TDMAPI_EVENT_RXHOOK:
|
||||
{
|
||||
zap_log(ZAP_LOG_DEBUG, "%d:%d rxhook, state %d\n", span->channels[i]->span_id, span->channels[i]->chan_id,
|
||||
tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_hook_state);
|
||||
if (span->channels[i]->type == ZAP_CHAN_TYPE_FXS) {
|
||||
event_id = tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_hook_state & WP_TDMAPI_EVENT_RXHOOK_OFF ? ZAP_OOB_OFFHOOK : ZAP_OOB_ONHOOK;
|
||||
if (event_id == ZAP_OOB_OFFHOOK) {
|
||||
|
|
Loading…
Reference in New Issue