]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: logging fixes, ss7 events sanity checks
authorNenad Corbic <ncorbic@sangoma.com>
Mon, 24 Oct 2011 23:40:45 +0000 (19:40 -0400)
committerNenad Corbic <ncorbic@sangoma.com>
Mon, 24 Oct 2011 23:40:45 +0000 (19:40 -0400)
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.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
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c

index bddcd39eca9008ff5b23109427c69e8b1acae579..790b893a8db36e91c695b48af135972b9adcfca4 100644 (file)
@@ -791,7 +791,7 @@ void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta)
                break;
        /**************************************************************************/
        case (LRY_USTA_UP): /* channel up */
-               ftdm_log(FTDM_LOG_ERROR,"[RELAY] Channel UP: tx procId %d: channel %d\n",
+               ftdm_log(FTDM_LOG_INFO,"[RELAY] Channel UP: tx procId %d: channel %d\n",
                                                                                                sta->t.usta.s.ryUpUsta.sendPid,
                                                                                                sta->t.usta.s.ryUpUsta.id);
 
index 049aa1546d33f2330773def9bb61bdbecf8dce73..759fd2871f96d4491d9d6816c8b7686e05b9c32a 100644 (file)
@@ -1651,6 +1651,7 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
 static ftdm_status_t ftdm_sangoma_ss7_stop(ftdm_span_t * span)
 {
        /*this function is called by the FT-Core to stop this span */
+       int timeout=0;
 
        ftdm_log (FTDM_LOG_INFO, "Stopping span %s:%u.\n", span->name,span->span_id);
 
@@ -1659,10 +1660,17 @@ static ftdm_status_t ftdm_sangoma_ss7_stop(ftdm_span_t * span)
 
        /* wait for the thread to stop */
        while (ftdm_test_flag (span, FTDM_SPAN_IN_THREAD)) {
-               ftdm_log (FTDM_LOG_DEBUG,"Waiting for monitor thread to end for %s:%u.\n",
+               ftdm_set_flag (span, FTDM_SPAN_STOP_THREAD);
+               ftdm_log (FTDM_LOG_DEBUG,"Waiting for monitor thread to end for %s:%u. [flags=0x%08X]\n",
                                                                        span->name,
-                                                                       span->span_id);
-               ftdm_sleep (1);
+                                                                       span->span_id,
+                                                                       span->flags);
+               /* Wait 50ms */
+               ftdm_sleep (50);
+               timeout++;
+
+               /* timeout after 5 sec, better to crash than hang */
+               ftdm_assert_return(timeout < 100, FTDM_FALSE, "SS7 Span stop timeout!\n");
        }
 
        /* KONRAD FIX ME - deconfigure any circuits, links, attached to this span */
@@ -1725,12 +1733,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);
                return FTDM_FAIL;
        }
 
        /* configure libsngss7 */
        if (ft_to_sngss7_cfg_all()) {
                ftdm_log (FTDM_LOG_CRIT, "Failed to configure LibSngSS7!\n");
+               ftdm_sleep (1000);
                return FTDM_FAIL;
        }
 
index 9bf24aada307e5aa51662a0c1980a69832a78cee..3fd5c6e46835dc3f1a97606ccefb6d4bb484c86b 100644 (file)
@@ -915,7 +915,7 @@ if (ftdmchan->state == new_state) { \
 #define SS7_ERROR_CHAN(fchan, msg, args...)    ftdm_log_chan(fchan, FTDM_LOG_ERROR, msg , ##args)
 #define SS7_CTRIT_CHAN(fchan, msg, args...)    ftdm_log_chan(fchan, FTDM_LOG_CRIT, msg , ##args)
 
-#ifdef KONRAD_DEVEL
+#ifdef SS7_CODE_DEVEL
 #define SS7_DEVEL_DEBUG(a,...)   ftdm_log(FTDM_LOG_DEBUG,a,##__VA_ARGS__ );
 #else
 #define SS7_DEVEL_DEBUG(a,...)
index 167de57bb8ab0cbbd8a26254d8f86b6ce498d517..3c1124b3d8903784c2f9383a1986709e7bd43da5 100644 (file)
@@ -922,11 +922,6 @@ int check_for_state_change(ftdm_channel_t *ftdmchan)
 /******************************************************************************/
 ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan)
 {
-       if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].obj == NULL) {
-               SS7_ERROR("sngss7_info is Null for circuit #%d\n", circuit);
-               return FTDM_FAIL;
-       }
-
        if (!g_ftdm_sngss7_data.cfg.isupCkt[circuit].obj) {
                SS7_ERROR("No ss7 info for circuit #%d\n", circuit);
                return FTDM_FAIL;
@@ -935,8 +930,19 @@ ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_in
        *sngss7_info = g_ftdm_sngss7_data.cfg.isupCkt[circuit].obj;
 
        if (!(*sngss7_info)->ftdmchan) {
-               SS7_ERROR("No channel for circuit #%d\n", circuit);
+               SS7_ERROR("No ftdmchan for circuit #%d\n", circuit);
+               return FTDM_FAIL;
+       }
+
+       if (!(*sngss7_info)->ftdmchan->span) {
+               SS7_CRITICAL("ftdmchan->span = NULL for circuit #%d\n",circuit);
                return FTDM_FAIL;
+               
+       }
+       if (!(*sngss7_info)->ftdmchan->span->signal_data) {
+               SS7_CRITICAL("ftdmchan->span->signal_data = NULL for circuit #%d\n",circuit);
+               return FTDM_FAIL;
+               
        }
 
        *ftdmchan = (*sngss7_info)->ftdmchan;
index 30d215a14dc4da0f78f8122aeade3e36bb513039..8edea31399d5b821b5d400e9d4b899ccffeb533b 100644 (file)
@@ -2877,7 +2877,7 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)
                                        (g_ftdm_sngss7_data.cfg.isupCkt[x].chan == count)) {
 
                                        /* we are processing a circuit that already exists */
-                                       SS7_DEBUG("Found an existing circuit %d, ccSpanId=%d, chan%d\n",
+                                       SS7_DEVEL_DEBUG("Found an existing circuit %d, ccSpanId=%d, chan%d\n",
                                                                x, 
                                                                ccSpan->id, 
                                                                count);
@@ -2886,7 +2886,7 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)
                                        flag = 1;
 
                                        /* not supporting reconfig at this time */
-                                       SS7_DEBUG("Not supporting ckt reconfig at this time!\n");
+                                       SS7_DEVEL_DEBUG("Not supporting ckt reconfig at this time!\n");
                                        goto move_along;
                                } else {
                                        /* this is not the droid you are looking for */