]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
automatically fail new tdm channel if ftdm_start_only is true
authorMathieu Rene <mrene@avgs.ca>
Fri, 27 Jul 2012 15:06:23 +0000 (11:06 -0400)
committerMathieu Rene <mrene@avgs.ca>
Fri, 27 Jul 2012 15:06:23 +0000 (11:06 -0400)
libs/freetdm/mod_freetdm/tdm.c

index efdf4dce3e68dcc2031ba64046a6eea2b29389e7..b2d37d47ed54c62508d4068a4368a88e8d5e50e2 100644 (file)
@@ -112,7 +112,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
     ftdm_codec_t codec;
     uint32_t interval;
     ftdm_status_t fstatus;
-    
+    const char *ftdm_start_only = switch_event_get_header(var_event, "ftdm_start_only");
     ctdm_private_t *tech_pvt = NULL;
     
     if (zstr(szchanid) || zstr(span_name)) {
@@ -129,6 +129,15 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
         goto fail;
     }
 
+    if ((fstatus = ftdm_span_start(span)) != FTDM_SUCCESS && fstatus != FTDM_EINVAL) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start span %s.\n", span_name);
+        goto fail;
+    }
+
+    if (!zstr(ftdm_start_only) && switch_true(ftdm_start_only)) {
+       goto fail;
+    }
+    
     
     if (!(*new_session = switch_core_session_request(ctdm.endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, 0, pool))) {
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't request session.\n");
@@ -137,11 +146,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
     
     channel = switch_core_session_get_channel(*new_session);
     
-    if ((fstatus = ftdm_span_start(span)) != FTDM_SUCCESS && fstatus != FTDM_EINVAL) {
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start span %s.\n", span_name);
-        goto fail;
-    }
-    
     if (ftdm_channel_open(span_id, chan_id, &chan) != FTDM_SUCCESS) {
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't open span or channel.\n"); 
         goto fail;