[Asterisk-cvs] asterisk asterisk.c, 1.165, 1.166 config.c, 1.71, 1.72 loader.c, 1.46, 1.47

kpfleming at lists.digium.com kpfleming at lists.digium.com
Tue Jul 5 18:02:50 CDT 2005


Update of /usr/cvsroot/asterisk
In directory localhost.localdomain:/tmp/cvs-serv1685

Modified Files:
	asterisk.c config.c loader.c 
Log Message:
add support for 'early loading' modules, so that nearly all configuration files can be read from Realtime storage
add warning for when file mapping is found but the engine is not available
add warning for trying to map 'logger.conf', since it cannot be reliably mapped


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -d -r1.165 -r1.166
--- asterisk.c	7 Jun 2005 16:07:06 -0000	1.165
+++ asterisk.c	5 Jul 2005 22:11:42 -0000	1.166
@@ -2081,6 +2081,11 @@
 		printf(term_quit());
 		exit(1);
 	}
+	/* load 'preload' modules, required for access to Realtime-mapped configuration files */
+	if (load_modules(1)) {
+		printf(term_quit());
+		exit(1);
+	}
 	ast_channels_init();
 	if (init_manager()) {
 		printf(term_quit());
@@ -2103,7 +2108,7 @@
 		printf(term_quit());
 		exit(1);
 	}
-	if (load_modules()) {
+	if (load_modules(0)) {
 		printf(term_quit());
 		exit(1);
 	}

Index: config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/config.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- config.c	5 Jul 2005 21:17:58 -0000	1.71
+++ config.c	5 Jul 2005 22:11:42 -0000	1.72
@@ -787,8 +787,18 @@
 		database = strsep(&stringp, ",");
 		table = strsep(&stringp, ",");
 			
-		if (!strcmp(v->name, extconfig_conf) || !strcmp(v->name, "asterisk.conf")) {
-			ast_log(LOG_WARNING, "Cannot bind asterisk.conf or extconfig.conf!\n");
+		if (!strcmp(v->name, extconfig_conf)) {
+			ast_log(LOG_WARNING, "Cannot bind '%s'!\n", extconfig_conf);
+			continue;
+		}
+
+		if (!strcmp(v->name, "asterisk.conf")) {
+			ast_log(LOG_WARNING, "Cannot bind 'asterisk.conf'!\n");
+			continue;
+		}
+
+		if (!strcmp(v->name, "logger.conf")) {
+			ast_log(LOG_WARNING, "Cannot bind 'logger.conf'!\n");
 			continue;
 		}
 

Index: loader.c
===================================================================
RCS file: /usr/cvsroot/asterisk/loader.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- loader.c	6 Jun 2005 22:12:18 -0000	1.46
+++ loader.c	5 Jul 2005 22:11:42 -0000	1.47
@@ -450,35 +450,53 @@
 	NULL,
 };
 
-int load_modules()
+int load_modules(const int preload_only)
 {
 	struct ast_config *cfg;
 	struct ast_variable *v;
 	char tmp[80];
-	if (option_verbose) 
-		ast_verbose( "Asterisk Dynamic Loader Starting:\n");
+
+	if (option_verbose) {
+		if (preload_only)
+			ast_verbose("Asterisk Dynamic Loader loading preload modules:\n");
+		else
+			ast_verbose("Asterisk Dynamic Loader Starting:\n");
+	}
+
 	cfg = ast_config_load(AST_MODULE_CONFIG);
 	if (cfg) {
+		int doload;
+
 		/* Load explicitly defined modules */
-		v = ast_variable_browse(cfg, "modules");
-		while(v) {
-			if (!strcasecmp(v->name, "load")) {
+		for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) {
+			doload = 0;
+
+			if (preload_only)
+				doload = !strcasecmp(v->name, "preload");
+			else
+				doload = !strcasecmp(v->name, "load");
+
+		       if (doload) {
 				if (option_debug && !option_verbose)
 					ast_log(LOG_DEBUG, "Loading module %s\n", v->value);
 				if (option_verbose) {
-					ast_verbose( VERBOSE_PREFIX_1 "[%s]", term_color(tmp, v->value, COLOR_BRWHITE, 0, sizeof(tmp)));
+					ast_verbose(VERBOSE_PREFIX_1 "[%s]", term_color(tmp, v->value, COLOR_BRWHITE, 0, sizeof(tmp)));
 					fflush(stdout);
 				}
 				if (__load_resource(v->value, cfg)) {
 					ast_log(LOG_WARNING, "Loading module %s failed!\n", v->value);
-					if (cfg)
-						ast_config_destroy(cfg);
+					ast_config_destroy(cfg);
 					return -1;
 				}
 			}
-			v=v->next;
 		}
 	}
+
+	if (preload_only) {
+		ast_config_destroy(cfg);
+		return 0;
+	}
+
 	if (!cfg || ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) {
 		/* Load all modules */
 		DIR *mods;




More information about the svn-commits mailing list