From dcaa0cf659550a1ef73216adb066fbd50b7295a7 Mon Sep 17 00:00:00 2001
From: Jonathan Rose <jrose@digium.com>
Date: Fri, 30 Aug 2013 18:04:41 +0000
Subject: [PATCH] features_config: Don't require features.conf to be present
 for Asterisk to load

(closes issue ASTERISK-22426)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2806/
........

Merged revisions 398020 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398064 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/features_config.c | 14 ++++++++++----
 main/udptl.c           | 13 ++++++++-----
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/main/features_config.c b/main/features_config.c
index ac4a1fec0d..fee1138623 100644
--- a/main/features_config.c
+++ b/main/features_config.c
@@ -1709,10 +1709,16 @@ static int load_config(void)
 			"", featuregroup_handler, 0);
 
 	if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {
-		ast_log(LOG_ERROR, "Failed to process features.conf configuration!\n");
-		aco_info_destroy(&cfg_info);
-		ao2_global_obj_release(globals);
-		return -1;
+		RAII_VAR(struct features_config *, features_cfg, __features_config_alloc(0), ao2_cleanup);
+
+		if (aco_set_defaults(&global_option, "general", features_cfg->global) ||
+			aco_set_defaults(&featuremap_option, "featuremap", features_cfg->featuremap)) {
+			ast_log(LOG_ERROR, "Failed to load features.conf and failed to initialize defaults.\n");
+			return -1;
+		}
+
+		ast_log(LOG_NOTICE, "Could not load features config; using defaults\n");
+		ao2_global_obj_replace(globals, features_cfg);
 	}
 
 	return 0;
diff --git a/main/udptl.c b/main/udptl.c
index d5d77388d6..25a4cc02c6 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -1458,14 +1458,17 @@ static int removed_options_handler(const struct aco_option *opt, struct ast_vari
 
 static void __ast_udptl_reload(int reload)
 {
-	RAII_VAR(struct udptl_config *, udptl_cfg, udptl_snapshot_alloc(), ao2_cleanup);
-
 	if (aco_process_config(&cfg_info, reload) == ACO_PROCESS_ERROR) {
 		if (!reload) {
-			if (!aco_set_defaults(&general_option, "general", udptl_cfg->general)) {
-				ast_log(LOG_WARNING, "Could not load udptl config; using defaults\n");
-				ao2_global_obj_replace(globals, udptl_cfg);
+			RAII_VAR(struct udptl_config *, udptl_cfg, udptl_snapshot_alloc(), ao2_cleanup);
+
+			if (aco_set_defaults(&general_option, "general", udptl_cfg->general)) {
+				ast_log(LOG_ERROR, "Failed to load udptl.conf and failed to initialize defaults.\n");
+				return;
 			}
+
+			ast_log(LOG_NOTICE, "Could not load udptl config; using defaults\n");
+			ao2_global_obj_replace(globals, udptl_cfg);
 		}
 	}
 }
-- 
GitLab