diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-09-21 22:53:17 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-09-21 22:53:17 +0000 |
commit | ed0fae08aa1ae087f3472e73d41227c8c8c3603d (patch) | |
tree | 02b166170f6c8273fac4565593355d2b18ef6357 | |
parent | 0ef853826f14edca8fbadfd921228e91cd09a5eb (diff) |
Oh look more changes, but these are my own! (Clean up module load functions)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@43461 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_iax2.c | 49 | ||||
-rw-r--r-- | channels/chan_sip.c | 22 |
2 files changed, 41 insertions, 30 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)", diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 291c321c2..f765cf1b4 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -16714,22 +16714,28 @@ static int load_module(void) ASTOBJ_CONTAINER_INIT(&peerl); /* Peer object list */ ASTOBJ_CONTAINER_INIT(®l); /* Registry object list */ - sched = sched_context_create(); - if (!sched) { - ast_log(LOG_WARNING, "Unable to create schedule context\n"); + if (!(sched = sched_context_create())) { + ast_log(LOG_ERROR, "Unable to create scheduler context\n"); + return AST_MODULE_LOAD_FAILURE; } - io = io_context_create(); - if (!io) { - ast_log(LOG_WARNING, "Unable to create I/O context\n"); + if (!(io = io_context_create())) { + ast_log(LOG_ERROR, "Unable to create I/O context\n"); + sched_context_destroy(sched); + return AST_MODULE_LOAD_FAILURE; } + sip_reloadreason = CHANNEL_MODULE_LOAD; + if(reload_config(sip_reloadreason)) /* Load the configuration from sip.conf */ return AST_MODULE_LOAD_DECLINE; + /* Make sure we can register our sip channel type */ if (ast_channel_register(&sip_tech)) { ast_log(LOG_ERROR, "Unable to register channel type 'SIP'\n"); - return -1; + io_context_destroy(io); + sched_context_destroy(sched); + return AST_MODULE_LOAD_FAILURE; } /* Register all CLI functions for SIP */ @@ -16763,7 +16769,7 @@ static int load_module(void) /* And start the monitor for the first time */ restart_monitor(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } static int unload_module(void) |