From 7e2ef3a55cdd77148941772f8170b72dc3b6c651 Mon Sep 17 00:00:00 2001 From: Nenad Corbic Date: Sun, 18 Dec 2011 23:02:59 -0500 Subject: [PATCH 1/3] freetdm: The remote hangup logic that waits for 3sec for FS to hanup up before hanging up the freetdm channel by force seems to have a memory leak. I have increased the timeout to 30sec and made the print statement WARNING level. --- libs/freetdm/src/ftdm_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 731b9f88ef..8b179ccf05 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -52,7 +52,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *result); #endif -#define FORCE_HANGUP_TIMER 3000 +#define FORCE_HANGUP_TIMER 30000 #define SPAN_PENDING_CHANS_QUEUE_SIZE 1000 #define SPAN_PENDING_SIGNALS_QUEUE_SIZE 1000 #define FTDM_READ_TRACE_INDEX 0 @@ -5455,7 +5455,7 @@ static void execute_safety_hangup(void *data) ftdm_channel_lock(fchan); fchan->hangup_timer = 0; if (fchan->state == FTDM_CHANNEL_STATE_TERMINATING) { - ftdm_log_chan(fchan, FTDM_LOG_NOTICE, "Forcing hangup since the user did not confirmed our hangup after %dms\n", FORCE_HANGUP_TIMER); + ftdm_log_chan(fchan, FTDM_LOG_WARNING, "Forcing hangup since the user did not confirmed our hangup after %dms\n", FORCE_HANGUP_TIMER); _ftdm_channel_call_hangup_nl(__FILE__, __FUNCTION__, __LINE__, fchan, NULL); } else { ftdm_log_chan(fchan, FTDM_LOG_CRIT, "Not performing safety hangup, channel state is %s\n", ftdm_channel_state2str(fchan->state)); From b6ca6c5b1da2d577d6ae95cbf0ce445ed59f2043 Mon Sep 17 00:00:00 2001 From: Nenad Corbic Date: Mon, 19 Dec 2011 02:27:38 -0500 Subject: [PATCH 2/3] freetdm: Added sng_cc_resource_check() On SIG Down we must not fail a call instead try hunting for another. The only time we can fail the call and not bother hunting is if sng_cc_resource_check fails. Took out configuration retry as the config code is now fixed in sng_ss7 library. Transaction id fix. Unit Tested: NSG UP -- start full load kill NSG NSG UP again on full load make sure it comes up fine. --- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c | 9 +++---- .../ftmod_sangoma_ss7_main.c | 25 +++++++++++-------- .../ftmod_sangoma_ss7_main.h | 6 +++++ 3 files changed, 24 insertions(+), 16 deletions(-) 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]; From 8eeb37a81b57226053caf9c2d151de721e4f6308 Mon Sep 17 00:00:00 2001 From: William Adam Date: Wed, 21 Dec 2011 14:56:03 -0500 Subject: [PATCH 3/3] Fixed bug#2215 - SPIROU transparent IAM max size error --- .../freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index f1c6625b85..f7d0171f93 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -1923,7 +1923,7 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) SS7_DEBUG("Found transparent_iam %d\n", sng_ccSpan.transparent_iam); #endif } else if (!strcasecmp(parm->var, "transparent_iam_max_size")) { - sng_ccSpan.transparent_iam_max_size = ftdm_true(parm->val); + sng_ccSpan.transparent_iam_max_size = atoi(parm->val); SS7_DEBUG("Found transparent_iam_max_size %d\n", sng_ccSpan.transparent_iam_max_size); } else if (!strcasecmp(parm->var, "cpg_on_progress_media")) { sng_ccSpan.cpg_on_progress_media = ftdm_true(parm->val);