]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
start boost spans only after all of them have been configured
authorMoises Silva <moy@sangoma.com>
Tue, 24 Nov 2009 18:15:55 +0000 (18:15 +0000)
committerMoises Silva <moy@sangoma.com>
Tue, 24 Nov 2009 18:15:55 +0000 (18:15 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@899 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/freetdm/mod_openzap/mod_openzap.c

index ba3e230d60b77f78045fa42a4bfc20cb5bb5da32..89e1e2a9f8c39c52d6cf30d32f37ba47417ea433 100644 (file)
@@ -1841,7 +1841,11 @@ static switch_status_t load_config(void)
 {
        const char *cf = "openzap.conf";
        switch_xml_t cfg, xml, settings, param, spans, myspan;
+       zap_span_t *boost_spans[ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN];
+       zap_span_t *boost_span = NULL;
+       unsigned boosti = 0;
 
+       memset(boost_spans, 0, sizeof(boost_spans));
        memset(&globals, 0, sizeof(globals));
        switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
        if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
@@ -2382,8 +2386,8 @@ static switch_status_t load_config(void)
                        switch_copy_string(SPAN_CONFIG[span->span_id].context, context, sizeof(SPAN_CONFIG[span->span_id].context));
                        switch_copy_string(SPAN_CONFIG[span->span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span->span_id].dialplan));
 
-                       zap_span_start(span);
                        switch_copy_string(SPAN_CONFIG[span->span_id].type, "Sangoma (boost)", sizeof(SPAN_CONFIG[span->span_id].type));
+                       boost_spans[boosti++] = span;
                }
        }
 
@@ -2552,6 +2556,19 @@ static switch_status_t load_config(void)
                }
        }
 
+       /* start all boost spans now that we're done configuring. Unfortunately at this point boost modules have the limitation
+        * of needing all spans to be configured before starting them */
+       unsigned i = 0;
+       for ( ; i < boosti; i++) {
+               boost_span = boost_spans[i];
+               zap_log(ZAP_LOG_DEBUG, "Starting boost span %d\n", boost_span->span_id);
+               if (zap_span_start(boost_span) == ZAP_FAIL) {
+                               zap_log(ZAP_LOG_ERROR, "Error starting boost OpenZAP span %d, error: %s\n", boost_span->span_id, boost_span->last_error);
+                               continue;
+               }
+       }
+
+
        switch_xml_free(xml);
 
        return SWITCH_STATUS_SUCCESS;