diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c index 25510e8c7a..327ca40f05 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c @@ -77,9 +77,9 @@ int ft_to_sngss7_cfg_all(void) int ret = 0; /* check if we have done gen_config already */ - if (!(g_ftdm_sngss7_data.gen_config)) { + if (g_ftdm_sngss7_data.gen_config == SNG_GEN_CFG_STATUS_INIT) { /* update the global gen_config so we don't do it again */ - g_ftdm_sngss7_data.gen_config = 1; + g_ftdm_sngss7_data.gen_config = SNG_GEN_CFG_STATUS_PENDING; /* start of by checking if the license and sig file are valid */ if (sng_validate_license(g_ftdm_sngss7_data.cfg.license, @@ -209,13 +209,12 @@ int ft_to_sngss7_cfg_all(void) } } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) */ - g_ftdm_sngss7_data.gen_config = 2; + g_ftdm_sngss7_data.gen_config = SNG_GEN_CFG_STATUS_DONE; } /* if (!(g_ftdm_sngss7_data.gen_config)) */ - /* FIXME: Please change number 2 to an ENUM that is more explanatory */ - if (g_ftdm_sngss7_data.gen_config != 2) { + if (g_ftdm_sngss7_data.gen_config != SNG_GEN_CFG_STATUS_DONE) { SS7_CRITICAL("General configuration FAILED!\n"); return 1; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index f6c61162b1..c963ea7cb7 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -1653,8 +1653,10 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call) /* check if the channel sig state is UP */ if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { - SS7_ERROR_CHAN(ftdmchan, "Requested channel sig state is down, cancelling call!%s\n", " "); - goto outgoing_fail; + SS7_ERROR_CHAN(ftdmchan, "Requested channel sig state is down, skipping channell!%s\n", " "); + /* Sig state will be down due to a block. + Right action is to hunt for another call */ + goto outgoing_break; } /* check if there is a remote block */ @@ -1679,6 +1681,14 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call) goto outgoing_break; } + + /* This is a gracefull stack resource check. + Removing this function will cause unpredictable + ungracefule errors. */ + if (sng_cc_resource_check()) { + goto outgoing_fail; + } + /* check the state of the channel */ switch (ftdmchan->state){ /**************************************************************************/ @@ -1873,7 +1883,6 @@ static ftdm_status_t ftdm_sangoma_ss7_stop(ftdm_span_t * span) static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_ss7_span_config) { sngss7_span_data_t *ss7_span_info; - int sngss7_retry_cnt=5; ftdm_log (FTDM_LOG_INFO, "Configuring ftmod_sangoma_ss7 span = %s(%d)...\n", span->name, @@ -1923,20 +1932,14 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_ss7_span_config) /* parse the configuration and apply to the global config structure */ if (ftmod_ss7_parse_xml(ftdm_parameters, span)) { ftdm_log (FTDM_LOG_CRIT, "Failed to parse configuration!\n"); - ftdm_sleep (1000); + ftdm_sleep (100); return FTDM_FAIL; } /* configure libsngss7 */ -try_cfg_again: if (ft_to_sngss7_cfg_all()) { - if (sngss7_retry_cnt--) { - ftdm_sleep (500); - ftdm_log (FTDM_LOG_DEBUG, "Failed to configure LibSngSS7 - retrying!\n"); - goto try_cfg_again; - } ftdm_log (FTDM_LOG_CRIT, "Failed to configure LibSngSS7!\n"); - ftdm_sleep (1000); + ftdm_sleep (100); return FTDM_FAIL; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index bb02d7e3ed..78210d50fb 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -116,6 +116,12 @@ typedef enum { SNG_CALLING = 2 } sng_addr_type_t; +typedef enum { + SNG_GEN_CFG_STATUS_INIT = 0, + SNG_GEN_CFG_STATUS_PENDING = 1, + SNG_GEN_CFG_STATUS_DONE = 2 +} nsg_gen_cfg_type_t; + typedef struct sng_mtp2_error_type { int init; char sng_type[MAX_NAME_LEN];