aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-07-05 22:11:43 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-07-05 22:11:43 +0000
commit97236cfc3232271c35e2abcf6884267e7495210f (patch)
tree32532d88234e6b8061d225229df28034faa45d2a
parent855799ac773c6e205fc33676ff24c19c73500169 (diff)
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 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6034 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xasterisk.c7
-rwxr-xr-xconfig.c14
-rwxr-xr-xconfigs/extconfig.conf.sample14
-rwxr-xr-xconfigs/modules.conf.sample10
-rwxr-xr-xinclude/asterisk.h2
-rwxr-xr-xloader.c38
6 files changed, 70 insertions, 15 deletions
diff --git a/asterisk.c b/asterisk.c
index e3daa1feb..249931ed3 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -2081,6 +2081,11 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
printf(term_quit());
exit(1);
}
- if (load_modules()) {
+ if (load_modules(0)) {
printf(term_quit());
exit(1);
}
diff --git a/config.c b/config.c
index dcb5c44e2..cef3d61cf 100755
--- a/config.c
+++ b/config.c
@@ -787,8 +787,18 @@ void read_config_maps(void)
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;
}
diff --git a/configs/extconfig.conf.sample b/configs/extconfig.conf.sample
index 56ca2d117..1cf923fb3 100755
--- a/configs/extconfig.conf.sample
+++ b/configs/extconfig.conf.sample
@@ -18,7 +18,19 @@
;uncomment to load queues.conf via the odbc engine.
;
;queues.conf => odbc,asterisk,ast_config
-
+;
+; The following files CANNOT be loaded from Realtime storage:
+; asterisk.conf
+; extconfig.conf (this file)
+; logger.conf
+;
+; Additionally, the following files cannot be loaded from
+; Realtime storage unless the storage driver is loaded
+; early using 'preload' statements in modules.conf:
+; manager.conf
+; cdr.conf
+; rtp.conf
+;
;
; Realtime configuration engine
;
diff --git a/configs/modules.conf.sample b/configs/modules.conf.sample
index 8dcee358c..7162b72da 100755
--- a/configs/modules.conf.sample
+++ b/configs/modules.conf.sample
@@ -7,6 +7,16 @@
[modules]
autoload=yes
;
+; Any modules that need to be loaded before the Asterisk core has been initialized
+; (just after the logger has been initialized) can be loaded using 'preload'. This
+; will frequently be needed if you wish to map all module configuration files into
+; Realtime storage, since the Realtime driver will need to be loaded before the
+; modules using those configuration files are initialized.
+;
+; An example of loading ODBC support would be:
+;preload => res_odbc.so
+;preload => res_config_odbc.so
+;
; If you want, load the GTK console right away.
; Don't load the KDE console since
; it's not as sophisticated right now.
diff --git a/include/asterisk.h b/include/asterisk.h
index 3b6f56590..afba16071 100755
--- a/include/asterisk.h
+++ b/include/asterisk.h
@@ -34,7 +34,7 @@ extern char ast_config_AST_SOCKET[AST_CONFIG_MAX_PATH];
extern char ast_config_AST_RUN_DIR[AST_CONFIG_MAX_PATH];
/* Provided by module.c */
-extern int load_modules(void);
+extern int load_modules(const int preload_only);
/* Provided by pbx.c */
extern int load_pbx(void);
/* Provided by logger.c */
diff --git a/loader.c b/loader.c
index 012491cc1..ec8585190 100755
--- a/loader.c
+++ b/loader.c
@@ -450,35 +450,53 @@ static const char *loadorder[] =
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;