diff options
author | Kinsey Moore <kmoore@digium.com> | 2013-09-20 22:44:11 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2013-09-20 22:44:11 +0000 |
commit | 6cc3084ae7bc927587865c1e3331fcc5031df9e7 (patch) | |
tree | d1837f4c351607c24b4cdae69d8363bbe6f6a95a /main/config_options.c | |
parent | 638577bef707f9c4964ea672aafe95d5d4509df3 (diff) |
Ensure global types in the config framework are initialized
If a config object was allocated but one of its global objects was
never encountered, then the global object's defaults were never
applied. Ensure that global objects are initialized properly upon
allocation instead of on configuration.
Review: https://reviewboard.asterisk.org/r/2866/
........
Merged revisions 399564 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 399565 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399566 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/config_options.c')
-rw-r--r-- | main/config_options.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/main/config_options.c b/main/config_options.c index 83b34028b..2733d5c62 100644 --- a/main/config_options.c +++ b/main/config_options.c @@ -478,10 +478,6 @@ static int process_category(struct ast_config *cfg, struct aco_info *info, struc } if (type->type == ACO_GLOBAL && *field) { - if (aco_set_defaults(type, cat, *field)) { - ast_log(LOG_ERROR, "In %s: Setting defaults for %s failed\n", file->filename, cat); - return -1; - } if (aco_process_category_options(type, cfg, cat, *field)) { ast_log(LOG_ERROR, "In %s: Processing options for %s failed\n", file->filename, cat); return -1; @@ -613,6 +609,27 @@ enum aco_process_status aco_process_config(struct aco_info *info, int reload) while (res != ACO_PROCESS_ERROR && (file = info->files[file_count++])) { const char *filename = file->filename; + struct aco_type *match; + int i; + + /* set defaults for global objects */ + for (i = 0, match = file->types[i]; match; match = file->types[++i]) { + void **field = info->internal->pending + match->item_offset; + + if (match->type != ACO_GLOBAL || !*field) { + continue; + } + + if (aco_set_defaults(match, match->category, *field)) { + ast_log(LOG_ERROR, "In %s: Setting defaults for %s failed\n", file->filename, match->category); + res = ACO_PROCESS_ERROR; + break; + } + } + + if (res == ACO_PROCESS_ERROR) { + break; + } try_alias: cfg = ast_config_load(filename, cfg_flags); |