]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: Added sng_cc_resource_check()
authorNenad Corbic <ncorbic@sangoma.com>
Mon, 19 Dec 2011 07:27:38 +0000 (02:27 -0500)
committerNenad Corbic <ncorbic@sangoma.com>
Mon, 19 Dec 2011 07:27:38 +0000 (02:27 -0500)
         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.

libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h

index 25510e8c7a8344415d47fb440dbaff6b174015c4..327ca40f0571105f44ea87d9aa7661d72568bef0 100644 (file)
@@ -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;
        }
index f6c61162b1c89a76969588ad0c6114e68b8045b4..c963ea7cb7d03b6a05fcfce6d47b1cc783277545 100644 (file)
@@ -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;
        }
 
index bb02d7e3ed6bc5c0a4fc4c7212193dabb5250074..78210d50fb26f2c74a25f9c289e18a6d2c90ad5c 100644 (file)
@@ -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];