summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2017-04-11 10:07:39 -0600
committerGeorge Joseph <gjoseph@digium.com>2017-04-12 15:57:21 -0600
commit747beb1ed159f89a3b58742e4257740b3d6d6bba (patch)
tree3ba17dd62d0270a9ee976f173f948304b1733773 /main
parent60fd01f7f4b43515f5d4d915eec701c6054c53cf (diff)
modules: change module LOAD_FAILUREs to LOAD_DECLINES
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed to AST_MODULE_LOAD_DECLINE. This prevents asterisk from exiting if a module can't be loaded. If the user wishes to retain the FAILURE behavior for a specific module, they can use the "require" or "preload-require" keyword in modules.conf. A new API was added to logger: ast_is_logger_initialized(). This allows asterisk.c/check_init() to print to the error log once the logger subsystem is ready instead of just to stdout. If something does fail before the logger is initialized, we now print to stderr instead of stdout. Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
Diffstat (limited to 'main')
-rw-r--r--main/asterisk.c6
-rw-r--r--main/loader.c1
-rw-r--r--main/logger.c5
3 files changed, 11 insertions, 1 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 68859ab2f..16313ea68 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -4354,7 +4354,11 @@ int main(int argc, char *argv[])
static inline void check_init(int init_result, const char *name)
{
if (init_result) {
- printf("%s initialization failed.\n%s", name, term_quit());
+ if (ast_is_logger_initialized()) {
+ ast_log(LOG_ERROR, "%s initialization failed. ASTERISK EXITING!\n%s", name, term_quit());
+ } else {
+ fprintf(stderr, "%s initialization failed. ASTERISK EXITING!\n%s", name, term_quit());
+ }
ast_run_atexits(0);
exit(init_result == -2 ? 2 : 1);
}
diff --git a/main/loader.c b/main/loader.c
index 380fe1c92..d5500076b 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -1243,6 +1243,7 @@ static int load_resource_list(struct load_order *load_order, unsigned int global
case AST_MODULE_LOAD_DECLINE:
break;
case AST_MODULE_LOAD_FAILURE:
+ ast_log(LOG_ERROR, "*** Failed to load module %s\n", mod->resource);
res = -1;
goto done;
case AST_MODULE_LOAD_SKIP:
diff --git a/main/logger.c b/main/logger.c
index 146d91985..8c8162d71 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -1653,6 +1653,11 @@ static void logger_queue_init(void)
}
}
+int ast_is_logger_initialized(void)
+{
+ return logger_initialized;
+}
+
/*!
* \brief Start the ast_queue_log() logger.
*