diff options
Diffstat (limited to 'res/res_ari.c')
-rw-r--r-- | res/res_ari.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/res/res_ari.c b/res/res_ari.c index c6f81dcef..809b7f65a 100644 --- a/res/res_ari.c +++ b/res/res_ari.c @@ -1103,6 +1103,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); @@ -1112,7 +1133,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 */ @@ -1122,10 +1143,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; } @@ -1137,33 +1160,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(); |