]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: ss7 - bug fix for race condition on startup causing seg fault
authorKonrad Hammel <konrad@sangoma.com>
Mon, 7 Mar 2011 16:36:18 +0000 (11:36 -0500)
committerKonrad Hammel <konrad@sangoma.com>
Wed, 9 Mar 2011 17:05:33 +0000 (12:05 -0500)
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c

index 331312fafb0d987f82c5f42238269be38491fc38..cb742ac4c9fb92b033b2fca07a957876584cddc1 100644 (file)
@@ -884,6 +884,12 @@ ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
 
+       /* confirm that the circuit is active on our side otherwise move to the next circuit */
+       if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) {
+               SS7_ERROR("[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic);
+               return FTDM_FAIL;
+       }
+
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
                SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -1189,6 +1195,13 @@ ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circui
                /* check that the infId matches and that this is not a siglink */
                if ((g_ftdm_sngss7_data.cfg.isupCkt[i].infId == infId) && 
                        (g_ftdm_sngss7_data.cfg.isupCkt[i].type == VOICE)) {
+
+                       /* confirm that the circuit is active on our side otherwise move to the next circuit */
+                       if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[i], SNGSS7_ACTIVE)) {
+                               SS7_ERROR("[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[i].cic);
+                               i++;
+                               continue;
+                       }
        
                        /* get the ftdmchan and ss7_chan_data from the circuit */
                        if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
@@ -1248,6 +1261,13 @@ ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circu
                if ((g_ftdm_sngss7_data.cfg.isupCkt[i].infId == infId) && 
                        (g_ftdm_sngss7_data.cfg.isupCkt[i].type == VOICE)) {
 
+                       /* confirm that the circuit is active on our side otherwise move to the next circuit */
+                       if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[i], SNGSS7_ACTIVE)) {
+                               SS7_ERROR("[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[i].cic);
+                               i++;
+                               continue;
+                       }
+
                        /* get the ftdmchan and ss7_chan_data from the circuit */
                        if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
                                SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
index 2f630fe462b82e589a22f7e20559e52e320d239b..10e73d3fbdda0dc07d46b95f63532f5078156e76 100644 (file)
@@ -1397,6 +1397,9 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
                /* lock the channel */
                ftdm_mutex_lock(ftdmchan->mutex);
 
+               /* flag the circuit as active */
+               sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE);
+
                /* check if the interface is paused or resumed */
                if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
                        SS7_DEBUG_CHAN(ftdmchan, "ISUP intf %d is PAUSED\n", sngss7_intf->id);