From: Richard Mudgett Date: Tue, 2 Oct 2018 18:29:59 +0000 (-0500) Subject: res_statsd.c: Made use defaults if the statsd.conf file does not exist. X-Git-Tag: 17.0.0-rc1~322^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a69a50b6ec8a3fae9dbe4cbec7a118de6db36ab5;p=thirdparty%2Fasterisk.git 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 --- diff --git a/res/res_statsd.c b/res/res_statsd.c index 3e0815218a..3e52c219b5 100644 --- a/res/res_statsd.c +++ b/res/res_statsd.c @@ -339,9 +339,25 @@ static int load_module(void) "", 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()) {