diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 430b58a31e..5e49fda520 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -634,6 +634,10 @@ static ftdm_status_t ftdm_span_destroy(ftdm_span_t *span) ftdm_mutex_lock(span->mutex); /* stop the signaling */ + + /* This is a forced stopped */ + ftdm_clear_flag(span, FTDM_SPAN_NON_STOPPABLE); + ftdm_span_stop(span); /* destroy the channels */ @@ -739,6 +743,11 @@ FT_DECLARE(ftdm_status_t) ftdm_span_stop(ftdm_span_t *span) ftdm_status_t status = FTDM_SUCCESS; ftdm_mutex_lock(span->mutex); + + if (ftdm_test_flag(span, FTDM_SPAN_NON_STOPPABLE)) { + status = FTDM_NOTIMPL; + goto done; + } if (!ftdm_test_flag(span, FTDM_SPAN_STARTED)) { status = FTDM_EINVAL; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index c13f584df8..97650245a1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -1094,6 +1094,7 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE); ftdm_set_flag(span, FTDM_SPAN_USE_PROCEED_STATE); ftdm_set_flag(span, FTDM_SPAN_USE_SKIP_STATES); + ftdm_set_flag(span, FTDM_SPAN_NON_STOPPABLE); if (span->trunk_type == FTDM_TRUNK_BRI_PTMP || span->trunk_type == FTDM_TRUNK_BRI) { diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h index d79835733b..3bc986d7f6 100644 --- a/libs/freetdm/src/include/private/ftdm_types.h +++ b/libs/freetdm/src/include/private/ftdm_types.h @@ -186,6 +186,9 @@ typedef enum { /* If this flag is set, the signalling module supports jumping directly to state up, without going through PROGRESS/PROGRESS_MEDIA */ FTDM_SPAN_USE_SKIP_STATES = (1 << 12), + /* If this flag is set, then this span cannot be stopped individually, it can only be stopped + on freetdm unload */ + FTDM_SPAN_NON_STOPPABLE = (1 << 13), } ftdm_span_flag_t; /*! \brief Channel supported features */