From dcfebf7bf6b94894f65fd5c6241cd639bdaaf110 Mon Sep 17 00:00:00 2001 From: markster Date: Tue, 9 Dec 2003 23:55:17 +0000 Subject: Cleanup unload calls git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1850 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_vofr.c | 115 +++++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 55 deletions(-) (limited to 'channels/chan_vofr.c') diff --git a/channels/chan_vofr.c b/channels/chan_vofr.c index 37d8a1f52..289e101a9 100755 --- a/channels/chan_vofr.c +++ b/channels/chan_vofr.c @@ -1136,61 +1136,7 @@ static struct ast_channel *vofr_request(char *type, int format, void *data) return tmp; } -int load_module() -{ - struct ast_config *cfg; - struct ast_variable *v; - struct vofr_pvt *tmp; - cfg = ast_load(config); - - /* We *must* have a config file otherwise stop immediately */ - if (!cfg) { - ast_log(LOG_ERROR, "Unable to load config %s\n", config); - return -1; - } - if (ast_mutex_lock(&iflock)) { - /* It's a little silly to lock it, but we mind as well just to be sure */ - ast_log(LOG_ERROR, "Unable to lock interface list???\n"); - return -1; - } - v = ast_variable_browse(cfg, "interfaces"); - while(v) { - /* Create the interface list */ - if (!strcasecmp(v->name, "user") || - !strcasecmp(v->name, "network")) { - tmp = mkif(v->name, v->value); - if (tmp) { - tmp->next = iflist; - iflist = tmp; - } else { - ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value); - ast_destroy(cfg); - ast_mutex_unlock(&iflock); - unload_module(); - return -1; - } - } else if (!strcasecmp(v->name, "context")) { - strncpy(context, v->value, sizeof(context)-1); - } else if (!strcasecmp(v->name, "language")) { - strncpy(language, v->value, sizeof(language)-1); - } - v = v->next; - } - ast_mutex_unlock(&iflock); - /* Make sure we can register our AdtranVoFR channel type */ - if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) { - ast_log(LOG_ERROR, "Unable to register channel class %s\n", type); - ast_destroy(cfg); - unload_module(); - return -1; - } - ast_destroy(cfg); - /* And start the monitor for the first time */ - restart_monitor(); - return 0; -} - -int unload_module() +static int __unload_module(void) { struct vofr_pvt *p, *pl; /* First, take us out of the channel loop */ @@ -1244,6 +1190,65 @@ int unload_module() return 0; } +int unload_module() +{ + return __unload_module(); +} + +int load_module() +{ + struct ast_config *cfg; + struct ast_variable *v; + struct vofr_pvt *tmp; + cfg = ast_load(config); + + /* We *must* have a config file otherwise stop immediately */ + if (!cfg) { + ast_log(LOG_ERROR, "Unable to load config %s\n", config); + return -1; + } + if (ast_mutex_lock(&iflock)) { + /* It's a little silly to lock it, but we mind as well just to be sure */ + ast_log(LOG_ERROR, "Unable to lock interface list???\n"); + return -1; + } + v = ast_variable_browse(cfg, "interfaces"); + while(v) { + /* Create the interface list */ + if (!strcasecmp(v->name, "user") || + !strcasecmp(v->name, "network")) { + tmp = mkif(v->name, v->value); + if (tmp) { + tmp->next = iflist; + iflist = tmp; + } else { + ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value); + ast_destroy(cfg); + ast_mutex_unlock(&iflock); + __unload_module(); + return -1; + } + } else if (!strcasecmp(v->name, "context")) { + strncpy(context, v->value, sizeof(context)-1); + } else if (!strcasecmp(v->name, "language")) { + strncpy(language, v->value, sizeof(language)-1); + } + v = v->next; + } + ast_mutex_unlock(&iflock); + /* Make sure we can register our AdtranVoFR channel type */ + if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) { + ast_log(LOG_ERROR, "Unable to register channel class %s\n", type); + ast_destroy(cfg); + __unload_module(); + return -1; + } + ast_destroy(cfg); + /* And start the monitor for the first time */ + restart_monitor(); + return 0; +} + int usecount() { int res; -- cgit v1.2.3