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
This commit is contained in:
George Joseph
2017-04-11 10:07:39 -06:00
parent 60fd01f7f4
commit 747beb1ed1
89 changed files with 431 additions and 340 deletions

View File

@@ -14886,7 +14886,7 @@ container_fail:
if (calltoken_ignores) {
ao2_ref(calltoken_ignores, -1);
}
return AST_MODULE_LOAD_FAILURE;
return -1;
}
@@ -15091,12 +15091,14 @@ static int load_module(void)
struct iax2_registry *reg = NULL;
if (!(iax2_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_append_by_type(iax2_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
if (load_objects()) {
return AST_MODULE_LOAD_FAILURE;
ao2_ref(iax2_tech.capabilities, -1);
iax2_tech.capabilities = NULL;
return AST_MODULE_LOAD_DECLINE;
}
memset(iaxs, 0, sizeof(iaxs));
@@ -15107,28 +15109,36 @@ static int load_module(void)
if (!(sched = ast_sched_context_create())) {
ast_log(LOG_ERROR, "Failed to create scheduler thread\n");
return AST_MODULE_LOAD_FAILURE;
ao2_ref(iax2_tech.capabilities, -1);
iax2_tech.capabilities = NULL;
return AST_MODULE_LOAD_DECLINE;
}
if (ast_sched_start_thread(sched)) {
ast_sched_context_destroy(sched);
ao2_ref(iax2_tech.capabilities, -1);
iax2_tech.capabilities = NULL;
sched = NULL;
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_DECLINE;
}
if (!(io = io_context_create())) {
ast_log(LOG_ERROR, "Failed to create I/O context\n");
ast_sched_context_destroy(sched);
ao2_ref(iax2_tech.capabilities, -1);
iax2_tech.capabilities = NULL;
sched = NULL;
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_DECLINE;
}
if (!(netsock = ast_netsock_list_alloc())) {
ast_log(LOG_ERROR, "Failed to create netsock list\n");
io_context_destroy(io);
ast_sched_context_destroy(sched);
ao2_ref(iax2_tech.capabilities, -1);
iax2_tech.capabilities = NULL;
sched = NULL;
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_DECLINE;
}
ast_netsock_init(netsock);
@@ -15137,8 +15147,10 @@ static int load_module(void)
ast_log(LOG_ERROR, "Could not allocate outsock list.\n");
io_context_destroy(io);
ast_sched_context_destroy(sched);
ao2_ref(iax2_tech.capabilities, -1);
iax2_tech.capabilities = NULL;
sched = NULL;
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_DECLINE;
}
ast_netsock_init(outsock);
@@ -15157,6 +15169,7 @@ static int load_module(void)
ast_timer_close(timer);
timer = NULL;
}
__unload_module();
return AST_MODULE_LOAD_DECLINE;
}
@@ -15182,7 +15195,7 @@ static int load_module(void)
if (ast_channel_register(&iax2_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", "IAX2");
__unload_module();
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_DECLINE;
}
if (ast_register_switch(&iax2_switch)) {
@@ -15192,7 +15205,7 @@ static int load_module(void)
if (start_network_thread()) {
ast_log(LOG_ERROR, "Unable to start network thread\n");
__unload_module();
return AST_MODULE_LOAD_FAILURE;
return AST_MODULE_LOAD_DECLINE;
} else {
ast_verb(2, "IAX Ready and Listening\n");
}