[asterisk-commits] kmoore: trunk r399566 - in /trunk: ./ main/config_options.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 20 17:44:16 CDT 2013


Author: kmoore
Date: Fri Sep 20 17:44:11 2013
New Revision: 399566

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399566
Log:
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

Modified:
    trunk/   (props changed)
    trunk/main/config_options.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Fri Sep 20 17:44:11 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399100,399136,399146,399160,399197,399207,399225,399237,399247,399257,399268,399283,399294,399339,399365,399376,399404,399458,399501,399514,399531,399553
+/branches/12:1-398558,398560-398577,398579-399100,399136,399146,399160,399197,399207,399225,399237,399247,399257,399268,399283,399294,399339,399365,399376,399404,399458,399501,399514,399531,399553,399565

Modified: trunk/main/config_options.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/config_options.c?view=diff&rev=399566&r1=399565&r2=399566
==============================================================================
--- trunk/main/config_options.c (original)
+++ trunk/main/config_options.c Fri Sep 20 17:44:11 2013
@@ -478,10 +478,6 @@
 	}
 
 	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 @@
 
 	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);




More information about the asterisk-commits mailing list