aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_vofr.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-12-09 23:55:17 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-12-09 23:55:17 +0000
commitdcfebf7bf6b94894f65fd5c6241cd639bdaaf110 (patch)
treee5e5eb37bd50d00a0215049ce584d248a60da5df /channels/chan_vofr.c
parent5d20155225cb149d6326defea641e47809d67fe6 (diff)
Cleanup unload calls
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1850 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_vofr.c')
-rwxr-xr-xchannels/chan_vofr.c115
1 files changed, 60 insertions, 55 deletions
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;