summaryrefslogtreecommitdiff
path: root/res/res_ari.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_ari.c')
-rw-r--r--res/res_ari.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/res/res_ari.c b/res/res_ari.c
index 549d78353..054d3bf3c 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -1106,6 +1106,27 @@ static struct ast_http_uri http_uri = {
.no_decode_uri = 1,
};
+static int unload_module(void)
+{
+ ast_ari_cli_unregister();
+
+ if (is_enabled()) {
+ ast_debug(3, "Disabling ARI\n");
+ ast_http_uri_unlink(&http_uri);
+ }
+
+ ast_ari_config_destroy();
+
+ ao2_cleanup(root_handler);
+ root_handler = NULL;
+ ast_mutex_destroy(&root_handler_lock);
+
+ ast_json_unref(oom_json);
+ oom_json = NULL;
+
+ return 0;
+}
+
static int load_module(void)
{
ast_mutex_init(&root_handler_lock);
@@ -1115,7 +1136,7 @@ static int load_module(void)
root_handler = root_handler_create();
}
if (!root_handler) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
/* oom_json may have been built during a declined load */
@@ -1125,10 +1146,12 @@ static int load_module(void)
}
if (!oom_json) {
/* Ironic */
- return AST_MODULE_LOAD_FAILURE;
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_ari_config_init() != 0) {
+ unload_module();
return AST_MODULE_LOAD_DECLINE;
}
@@ -1140,33 +1163,13 @@ static int load_module(void)
}
if (ast_ari_cli_register() != 0) {
- return AST_MODULE_LOAD_FAILURE;
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;
}
-static int unload_module(void)
-{
- ast_ari_cli_unregister();
-
- if (is_enabled()) {
- ast_debug(3, "Disabling ARI\n");
- ast_http_uri_unlink(&http_uri);
- }
-
- ast_ari_config_destroy();
-
- ao2_cleanup(root_handler);
- root_handler = NULL;
- ast_mutex_destroy(&root_handler_lock);
-
- ast_json_unref(oom_json);
- oom_json = NULL;
-
- return 0;
-}
-
static int reload_module(void)
{
char was_enabled = is_enabled();