mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-02 02:18:31 +00:00
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:
@@ -358,9 +358,20 @@ db_reconnect:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_strings(void)
|
||||
{
|
||||
struct unload_string *us;
|
||||
|
||||
AST_LIST_LOCK(&unload_strings);
|
||||
while ((us = AST_LIST_REMOVE_HEAD(&unload_strings, entry))) {
|
||||
ast_free(us->str);
|
||||
ast_free(us);
|
||||
}
|
||||
AST_LIST_UNLOCK(&unload_strings);
|
||||
}
|
||||
|
||||
static int my_unload_module(int reload)
|
||||
{
|
||||
struct unload_string *us;
|
||||
struct column *entry;
|
||||
|
||||
ast_cli_unregister_multiple(cdr_mysql_status_cli, sizeof(cdr_mysql_status_cli) / sizeof(struct ast_cli_entry));
|
||||
@@ -371,12 +382,7 @@ static int my_unload_module(int reload)
|
||||
records = 0;
|
||||
}
|
||||
|
||||
AST_LIST_LOCK(&unload_strings);
|
||||
while ((us = AST_LIST_REMOVE_HEAD(&unload_strings, entry))) {
|
||||
ast_free(us->str);
|
||||
ast_free(us);
|
||||
}
|
||||
AST_LIST_UNLOCK(&unload_strings);
|
||||
free_strings();
|
||||
|
||||
if (!reload) {
|
||||
AST_RWLIST_WRLOCK(&columns);
|
||||
@@ -512,13 +518,16 @@ static int my_load_module(int reload)
|
||||
} else {
|
||||
calldate_compat = 0;
|
||||
}
|
||||
ast_free(compat);
|
||||
|
||||
if (res < 0) {
|
||||
if (reload) {
|
||||
AST_RWLIST_UNLOCK(&columns);
|
||||
}
|
||||
ast_config_destroy(cfg);
|
||||
return AST_MODULE_LOAD_FAILURE;
|
||||
free_strings();
|
||||
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
/* Check for any aliases */
|
||||
@@ -589,7 +598,9 @@ static int my_load_module(int reload)
|
||||
connected = 0;
|
||||
AST_RWLIST_UNLOCK(&columns);
|
||||
ast_config_destroy(cfg);
|
||||
return AST_MODULE_LOAD_FAILURE;
|
||||
free_strings();
|
||||
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
if (!(result = mysql_store_result(&mysql))) {
|
||||
@@ -598,7 +609,9 @@ static int my_load_module(int reload)
|
||||
connected = 0;
|
||||
AST_RWLIST_UNLOCK(&columns);
|
||||
ast_config_destroy(cfg);
|
||||
return AST_MODULE_LOAD_FAILURE;
|
||||
free_strings();
|
||||
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
@@ -664,7 +677,8 @@ static int my_load_module(int reload)
|
||||
AST_RWLIST_UNLOCK(&columns);
|
||||
ast_config_destroy(cfg);
|
||||
if (res < 0) {
|
||||
return AST_MODULE_LOAD_FAILURE;
|
||||
my_unload_module(0);
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
if (!reload) {
|
||||
@@ -678,7 +692,12 @@ static int my_load_module(int reload)
|
||||
res = ast_cli_register_multiple(cdr_mysql_status_cli, sizeof(cdr_mysql_status_cli) / sizeof(struct ast_cli_entry));
|
||||
}
|
||||
|
||||
return res;
|
||||
if (res) {
|
||||
my_unload_module(0);
|
||||
return AST_MODULE_LOAD_DECLINE;
|
||||
}
|
||||
|
||||
return AST_MODULE_LOAD_SUCCESS;
|
||||
}
|
||||
|
||||
static int load_module(void)
|
||||
|
Reference in New Issue
Block a user