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 2e9f186c17
commit f882ca2572
89 changed files with 461 additions and 368 deletions

View File

@@ -926,6 +926,26 @@ static struct ast_cli_entry cli_alsa[] = {
AST_CLI_DEFINE(console_mute, "Disable/Enable mic input"),
};
static int unload_module(void)
{
ast_channel_unregister(&alsa_tech);
ast_cli_unregister_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
if (alsa.icard)
snd_pcm_close(alsa.icard);
if (alsa.ocard)
snd_pcm_close(alsa.ocard);
if (alsa.owner)
ast_softhangup(alsa.owner, AST_SOFTHANGUP_APPUNLOAD);
if (alsa.owner)
return -1;
ao2_cleanup(alsa_tech.capabilities);
alsa_tech.capabilities = NULL;
return 0;
}
/*!
* \brief Load the module
*
@@ -996,12 +1016,16 @@ static int load_module(void)
if (soundcard_init() < 0) {
ast_verb(2, "No sound card detected -- console channel will be unavailable\n");
ast_verb(2, "Turn off ALSA support by adding 'noload=chan_alsa.so' in /etc/asterisk/modules.conf\n");
unload_module();
return AST_MODULE_LOAD_DECLINE;
}
if (ast_channel_register(&alsa_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
return AST_MODULE_LOAD_FAILURE;
unload_module();
return AST_MODULE_LOAD_DECLINE;
}
ast_cli_register_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
@@ -1009,26 +1033,6 @@ static int load_module(void)
return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)
{
ast_channel_unregister(&alsa_tech);
ast_cli_unregister_multiple(cli_alsa, ARRAY_LEN(cli_alsa));
if (alsa.icard)
snd_pcm_close(alsa.icard);
if (alsa.ocard)
snd_pcm_close(alsa.ocard);
if (alsa.owner)
ast_softhangup(alsa.owner, AST_SOFTHANGUP_APPUNLOAD);
if (alsa.owner)
return -1;
ao2_cleanup(alsa_tech.capabilities);
alsa_tech.capabilities = NULL;
return 0;
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ALSA Console Channel Driver",
.support_level = AST_MODULE_SUPPORT_EXTENDED,
.load = load_module,