From bb875ce6ff692c129647206ce8956a01fcb8f9d0 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Tue, 15 May 2012 19:45:36 -0400 Subject: [PATCH] mod_megaco: add sample config file and refuse to start a profile without a configuration --- src/mod/endpoints/mod_megaco/conf/megaco.conf.xml | 9 +++++++++ src/mod/endpoints/mod_megaco/megaco.c | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/mod/endpoints/mod_megaco/conf/megaco.conf.xml diff --git a/src/mod/endpoints/mod_megaco/conf/megaco.conf.xml b/src/mod/endpoints/mod_megaco/conf/megaco.conf.xml new file mode 100644 index 0000000000..c219023dd8 --- /dev/null +++ b/src/mod/endpoints/mod_megaco/conf/megaco.conf.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/mod/endpoints/mod_megaco/megaco.c b/src/mod/endpoints/mod_megaco/megaco.c index 72d03424f1..9ac7af4355 100644 --- a/src/mod/endpoints/mod_megaco/megaco.c +++ b/src/mod/endpoints/mod_megaco/megaco.c @@ -56,7 +56,8 @@ static switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t r count = switch_event_import_xml(switch_xml_child(x_settings, "param"), "name", "value", &event); // status = switch_xml_config_parse_event(event, count, reload, instructions); - /* TODO: Initialize stack configuration */ + /* TODO: Kapil: Initialize stack configuration */ + status = SWITCH_STATUS_SUCCESS; } done: @@ -87,12 +88,17 @@ switch_status_t megaco_profile_start(const char *profilename) switch_thread_rwlock_create(&profile->rwlock, pool); /* TODO: Kapil: Insert stack per-interface startup code here */ + if (config_profile(profile, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error configuring profile %s\n", profile->name); + goto fail; + } switch_core_hash_insert_wrlock(megaco_globals.profile_hash, profile->name, profile, megaco_globals.profile_rwlock); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Started profile: %s\n", profile->name); return SWITCH_STATUS_SUCCESS; + fail: switch_core_destroy_memory_pool(&pool); return SWITCH_STATUS_FALSE;