summaryrefslogtreecommitdiff
path: root/channels/chan_iax2.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r--channels/chan_iax2.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 38dc5c00e..d15b55d72 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -14886,7 +14886,7 @@ container_fail:
if (calltoken_ignores) {
ao2_ref(calltoken_ignores, -1);
}
- return AST_MODULE_LOAD_FAILURE;
+ return -1;
}
@@ -15091,12 +15091,14 @@ static int load_module(void)
struct iax2_registry *reg = NULL;
if (!(iax2_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_format_cap_append_by_type(iax2_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
if (load_objects()) {
- return AST_MODULE_LOAD_FAILURE;
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
+ return AST_MODULE_LOAD_DECLINE;
}
memset(iaxs, 0, sizeof(iaxs));
@@ -15107,28 +15109,36 @@ static int load_module(void)
if (!(sched = ast_sched_context_create())) {
ast_log(LOG_ERROR, "Failed to create scheduler thread\n");
- return AST_MODULE_LOAD_FAILURE;
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_sched_start_thread(sched)) {
ast_sched_context_destroy(sched);
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
sched = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(io = io_context_create())) {
ast_log(LOG_ERROR, "Failed to create I/O context\n");
ast_sched_context_destroy(sched);
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
sched = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (!(netsock = ast_netsock_list_alloc())) {
ast_log(LOG_ERROR, "Failed to create netsock list\n");
io_context_destroy(io);
ast_sched_context_destroy(sched);
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
sched = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_netsock_init(netsock);
@@ -15137,8 +15147,10 @@ static int load_module(void)
ast_log(LOG_ERROR, "Could not allocate outsock list.\n");
io_context_destroy(io);
ast_sched_context_destroy(sched);
+ ao2_ref(iax2_tech.capabilities, -1);
+ iax2_tech.capabilities = NULL;
sched = NULL;
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
ast_netsock_init(outsock);
@@ -15157,6 +15169,7 @@ static int load_module(void)
ast_timer_close(timer);
timer = NULL;
}
+ __unload_module();
return AST_MODULE_LOAD_DECLINE;
}
@@ -15182,7 +15195,7 @@ static int load_module(void)
if (ast_channel_register(&iax2_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", "IAX2");
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
}
if (ast_register_switch(&iax2_switch)) {
@@ -15192,7 +15205,7 @@ static int load_module(void)
if (start_network_thread()) {
ast_log(LOG_ERROR, "Unable to start network thread\n");
__unload_module();
- return AST_MODULE_LOAD_FAILURE;
+ return AST_MODULE_LOAD_DECLINE;
} else {
ast_verb(2, "IAX Ready and Listening\n");
}