summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
Diffstat (limited to 'addons')
-rw-r--r--addons/cdr_mysql.c43
-rw-r--r--addons/chan_mobile.c11
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",