From 3b47c0786b6d05417fe6d895d75a33c67a3eeca2 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 24 Nov 2009 18:15:55 +0000 Subject: [PATCH] start boost spans only after all of them have been configured 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 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/mod_openzap/mod_openzap.c b/libs/freetdm/mod_openzap/mod_openzap.c index ba3e230d60..89e1e2a9f8 100644 --- a/libs/freetdm/mod_openzap/mod_openzap.c +++ b/libs/freetdm/mod_openzap/mod_openzap.c @@ -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;