diff options
author | Joshua Colp <jcolp@digium.com> | 2006-09-21 22:53:17 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2006-09-21 22:53:17 +0000 |
commit | 323527b4f370abbd21d64c0b80773fe7a27a3873 (patch) | |
tree | 02b166170f6c8273fac4565593355d2b18ef6357 /channels/chan_iax2.c | |
parent | 57504cf0f1b75f5cd21f7b4f1a6a41c14c34b86e (diff) |
Oh look more changes, but these are my own! (Clean up module load functions)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43461 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index c4d48b096..6fad93b45 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -9890,8 +9890,7 @@ static int unload_module(void) static int load_module(void) { char *config = "iax.conf"; - int res = 0; - int x; + int x = 0; struct iax2_registry *reg = NULL; struct iax2_peer *peer = NULL; @@ -9915,20 +9914,25 @@ static int load_module(void) for (x=0;x<IAX_MAX_CALLS;x++) ast_mutex_init(&iaxsl[x]); - - io = io_context_create(); - sched = sched_context_create(); - - if (!io || !sched) { - ast_log(LOG_ERROR, "Out of memory\n"); - return -1; + + if (!(sched = sched_context_create())) { + ast_log(LOG_ERROR, "Failed to create scheduler context\n"); + return AST_MODULE_LOAD_FAILURE; } - netsock = ast_netsock_list_alloc(); - if (!netsock) { - ast_log(LOG_ERROR, "Could not allocate netsock list.\n"); - return -1; + if (!(io = io_context_create())) { + ast_log(LOG_ERROR, "Failed to create I/O context\n"); + sched_context_destroy(sched); + return AST_MODULE_LOAD_FAILURE; + } + + if (!(netsock = ast_netsock_list_alloc())) { + ast_log(LOG_ERROR, "Failed to create netsock list\n"); + io_context_destroy(io); + sched_context_destroy(sched); + return AST_MODULE_LOAD_FAILURE; } + ast_netsock_init(netsock); ast_mutex_init(&waresl.lock); @@ -9946,23 +9950,22 @@ 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 -1; + return AST_MODULE_LOAD_FAILURE; } if (ast_register_switch(&iax2_switch)) ast_log(LOG_ERROR, "Unable to register IAX switch\n"); - res = start_network_thread(); - if (!res) { - if (option_verbose > 1) - ast_verbose(VERBOSE_PREFIX_2 "IAX Ready and Listening\n"); - } else { + if (start_network_thread()) { ast_log(LOG_ERROR, "Unable to start network thread\n"); - ast_netsock_release(netsock); - } + __unload_module(); + return AST_MODULE_LOAD_FAILURE; + } else if (option_verbose > 1) + ast_verbose(VERBOSE_PREFIX_2 "IAX Ready and Listening\n"); for (reg = registrations; reg; reg = reg->next) iax2_do_register(reg); + AST_LIST_LOCK(&peers); AST_LIST_TRAVERSE(&peers, peer, entry) { if (peer->sockfd < 0) @@ -9970,9 +9973,11 @@ static int load_module(void) iax2_poke_peer(peer, 0); } AST_LIST_UNLOCK(&peers); + reload_firmware(); iax_provision_reload(); - return res; + + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Inter Asterisk eXchange (Ver 2)", |