diff options
author | George Joseph <gjoseph@digium.com> | 2017-04-11 10:07:39 -0600 |
---|---|---|
committer | George Joseph <gjoseph@digium.com> | 2017-04-12 15:57:21 -0600 |
commit | 747beb1ed159f89a3b58742e4257740b3d6d6bba (patch) | |
tree | 3ba17dd62d0270a9ee976f173f948304b1733773 /addons | |
parent | 60fd01f7f4b43515f5d4d915eec701c6054c53cf (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 'addons')
-rw-r--r-- | addons/cdr_mysql.c | 43 | ||||
-rw-r--r-- | addons/chan_mobile.c | 11 |
2 files changed, 39 insertions, 15 deletions
diff --git a/addons/cdr_mysql.c b/addons/cdr_mysql.c index 0878950e1..f8f4192ac 100644 --- a/addons/cdr_mysql.c +++ b/addons/cdr_mysql.c @@ -351,9 +351,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)); @@ -364,12 +375,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); @@ -505,13 +511,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 */ @@ -582,7 +591,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))) { @@ -591,7 +602,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))) { @@ -657,7 +670,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) { @@ -671,7 +685,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) diff --git a/addons/chan_mobile.c b/addons/chan_mobile.c index bd39bee64..8f04af753 100644 --- a/addons/chan_mobile.c +++ b/addons/chan_mobile.c @@ -4704,9 +4704,13 @@ static int load_module(void) ast_format_cap_append(mbl_tech.capabilities, DEVICE_FRAME_FORMAT, 0); /* Check if we have Bluetooth, no point loading otherwise... */ dev_id = hci_get_route(NULL); + s = hci_open_dev(dev_id); if (dev_id < 0 || s < 0) { ast_log(LOG_ERROR, "No Bluetooth devices found. Not loading module.\n"); + ao2_ref(mbl_tech.capabilities, -1); + mbl_tech.capabilities = NULL; + hci_close_dev(s); return AST_MODULE_LOAD_DECLINE; } @@ -4714,6 +4718,8 @@ static int load_module(void) if (mbl_load_config()) { ast_log(LOG_ERROR, "Errors reading config file %s. Not loading module.\n", MBL_CONFIG); + ao2_ref(mbl_tech.capabilities, -1); + mbl_tech.capabilities = NULL; return AST_MODULE_LOAD_DECLINE; } @@ -4738,10 +4744,9 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; e_cleanup: - if (sdp_session) - sdp_close(sdp_session); + unload_module(); - return AST_MODULE_LOAD_FAILURE; + return AST_MODULE_LOAD_DECLINE; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Bluetooth Mobile Device Channel Driver", |