[Asterisk-code-review] res statsd.c: Made use defaults if the statsd.conf file does... (asterisk[16])

George Joseph asteriskteam at digium.com
Fri Oct 5 10:10:53 CDT 2018


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/10385 )

Change subject: res_statsd.c: Made use defaults if the statsd.conf file does not exist.
......................................................................

res_statsd.c: Made use defaults if the statsd.conf file does not exist.

This module is an optional dependency of many modules.  If it declines to
load it then forces other modules that can optionally use this module to
also decline.

* Made use default configuration if there is a config error or the config
file does not exist.

Change-Id: If1068a582ec54ab7fb437265cb5370a97a825737
---
M res/res_statsd.c
1 file changed, 19 insertions(+), 3 deletions(-)

Approvals:
  Corey Farrell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/res/res_statsd.c b/res/res_statsd.c
index 3e08152..3e52c21 100644
--- a/res/res_statsd.c
+++ b/res/res_statsd.c
@@ -339,9 +339,25 @@
 		"", OPT_CHAR_ARRAY_T, 0,
 		CHARFLDSET(struct conf_global_options, prefix));
 
-	if (aco_process_config(&cfg_info, 0)) {
-		aco_info_destroy(&cfg_info);
-		return AST_MODULE_LOAD_DECLINE;
+	if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {
+		struct conf *cfg;
+
+		ast_log(LOG_NOTICE, "Could not load statsd config; using defaults\n");
+		cfg = conf_alloc();
+		if (!cfg) {
+			aco_info_destroy(&cfg_info);
+			return AST_MODULE_LOAD_DECLINE;
+		}
+
+		if (aco_set_defaults(&global_option, "general", cfg->global)) {
+			ast_log(LOG_ERROR, "Failed to initialize statsd defaults.\n");
+			ao2_ref(cfg, -1);
+			aco_info_destroy(&cfg_info);
+			return AST_MODULE_LOAD_DECLINE;
+		}
+
+		ao2_global_obj_replace_unref(confs, cfg);
+		ao2_ref(cfg, -1);
 	}
 
 	if (!is_enabled()) {

-- 
To view, visit https://gerrit.asterisk.org/10385
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: merged
Gerrit-Change-Id: If1068a582ec54ab7fb437265cb5370a97a825737
Gerrit-Change-Number: 10385
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181005/e67ff9b2/attachment-0001.html>


More information about the asterisk-code-review mailing list