more module loader related fixes
authorKevin P. Fleming <kpfleming@digium.com>
Mon, 17 Apr 2006 16:42:21 +0000 (16:42 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Mon, 17 Apr 2006 16:42:21 +0000 (16:42 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20963 65c4cc65-6c06-0410-ace0-fbb531ad65f3

cdr/cdr_pgsql.c
cdr/cdr_sqlite.c
cdr/cdr_tds.c
channels/chan_alsa.c
channels/chan_misdn.c
channels/chan_nbs.c
channels/chan_vpb.c

index 438d526..139a1e7 100644 (file)
@@ -176,7 +176,7 @@ static int pgsql_log(struct ast_cdr *cdr)
        return 0;
 }
 
-const char *description(void)
+static const char *description(void)
 {
        return desc;
 }
@@ -326,34 +326,25 @@ static int my_load_module(void)
        return res;
 }
 
-int load_module(void)
+static int load_module(void *mod)
 {
        return my_load_module();
 }
 
-int unload_module(void)
+static int unload_module(void *mod)
 {
        return my_unload_module();
 }
 
-int reload(void)
+static int reload(void *mod)
 {
        my_unload_module();
        return my_load_module();
 }
 
-int usecount(void)
-{
-       /* To be able to unload the module */
-       if ( ast_mutex_trylock(&pgsql_lock) ) {
-               return 1;
-       } else {
-               ast_mutex_unlock(&pgsql_lock);
-               return 0;
-       }
-}
-
-const char *key()
+static const char *key(void)
 {
        return ASTERISK_GPL_KEY;
 }
+
+STD_MOD(MOD_0, reload, NULL, NULL);
index 6da0398..1982c7d 100644 (file)
@@ -164,12 +164,12 @@ static int sqlite_log(struct ast_cdr *cdr)
 }
 
 
-const char *description(void)
+static const char *description(void)
 {
        return desc;
 }
 
-int unload_module(void)
+static int unload_module(void *mod)
 {
        if (db)
                sqlite_close(db);
@@ -177,7 +177,7 @@ int unload_module(void)
        return 0;
 }
 
-int load_module(void)
+static int load_module(void *mod)
 {
        char *zErr;
        char fn[PATH_MAX];
@@ -218,17 +218,14 @@ err:
        return -1;
 }
 
-int reload(void)
+static int reload(void *mod)
 {
        return 0;
 }
 
-int usecount(void)
-{
-       return 0;
-}
-
-const char *key()
+static const char *key(void)
 {
        return ASTERISK_GPL_KEY;
 }
+
+STD_MOD(MOD_0, reload, NULL, NULL);
index 7563543..2a812a1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2004 - 2005, Digium, Inc.
+ * Copyright (C) 2004 - 2006, Digium, Inc.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -293,7 +293,7 @@ static void get_date(char *dateField, struct timeval tv)
        }
 }
 
-const char *description(void)
+static const char *description(void)
 {
        return desc;
 }
@@ -499,34 +499,25 @@ static int tds_load_module(void)
        return res;
 }
 
-int reload(void)
+static int reload(void *mod)
 {
        tds_unload_module();
        return tds_load_module();
 }
 
-int load_module(void)
+static int load_module(void *mod)
 {
        return tds_load_module();
 }
 
-int unload_module(void)
+static int unload_module(void *mod)
 {
        return tds_unload_module();
 }
 
-int usecount(void)
-{
-       /* Simplistic use count */
-       if (ast_mutex_trylock(&tds_lock)) {
-               return 1;
-       } else {
-               ast_mutex_unlock(&tds_lock);
-               return 0;
-       }
-}
-
-const char *key()
+static const char *key(void)
 {
        return ASTERISK_GPL_KEY;
 }
+
+STD_MOD(MOD_0, reload, NULL, NULL);
index 9714c3f..b2bc270 100644 (file)
@@ -1042,7 +1042,7 @@ static struct ast_cli_entry myclis[] = {
        { { "autoanswer", NULL }, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete }
 };
 
-int load_module()
+int load_module(void)
 {
        int res;
        int x;
@@ -1103,7 +1103,7 @@ int load_module()
 
 
 
-int unload_module()
+int unload_module(void)
 {
        int x;
        
@@ -1125,17 +1125,17 @@ int unload_module()
        return 0;
 }
 
-const char *description()
+const char *description(void)
 {
        return (char *) desc;
 }
 
-int usecount()
+int usecount(void)
 {
        return usecnt;
 }
 
-const char *key()
+const char *key(void)
 {
        return ASTERISK_GPL_KEY;
 }
index 08e9d55..b5a6499 100644 (file)
@@ -3827,6 +3827,51 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
 
 static int g_config_initialized=0;
 
+int unload_module(void)
+{
+       /* First, take us out of the channel loop */
+       ast_log(LOG_VERBOSE, "-- Unregistering mISDN Channel Driver --\n");
+       
+       if (!g_config_initialized) return 0;
+       
+       ast_cli_unregister(&cli_send_display);
+       
+       ast_cli_unregister(&cli_send_cd);
+       
+       ast_cli_unregister(&cli_send_digit);
+       ast_cli_unregister(&cli_toggle_echocancel);
+       ast_cli_unregister(&cli_set_tics);
+  
+       ast_cli_unregister(&cli_show_cls);
+       ast_cli_unregister(&cli_show_cl);
+       ast_cli_unregister(&cli_show_config);
+       ast_cli_unregister(&cli_show_port);
+       ast_cli_unregister(&cli_show_stacks);
+       ast_cli_unregister(&cli_restart_port);
+       ast_cli_unregister(&cli_port_up);
+       ast_cli_unregister(&cli_port_down);
+       ast_cli_unregister(&cli_set_debug);
+       ast_cli_unregister(&cli_set_crypt_debug);
+       ast_cli_unregister(&cli_reload);
+       /* ast_unregister_application("misdn_crypt"); */
+       ast_unregister_application("misdn_set_opt");
+       ast_unregister_application("misdn_facility");
+  
+       ast_channel_unregister(&misdn_tech);
+
+
+       free_robin_list();
+       misdn_cfg_destroy();
+       misdn_lib_destroy();
+  
+       if (misdn_debug)
+               free(misdn_debug);
+       if (misdn_debug_only)
+               free(misdn_debug_only);
+       
+       return 0;
+}
+
 int load_module(void)
 {
        int i;
@@ -3934,51 +3979,6 @@ int load_module(void)
 
 
 
-int unload_module(void)
-{
-       /* First, take us out of the channel loop */
-       ast_log(LOG_VERBOSE, "-- Unregistering mISDN Channel Driver --\n");
-       
-       if (!g_config_initialized) return 0;
-       
-       ast_cli_unregister(&cli_send_display);
-       
-       ast_cli_unregister(&cli_send_cd);
-       
-       ast_cli_unregister(&cli_send_digit);
-       ast_cli_unregister(&cli_toggle_echocancel);
-       ast_cli_unregister(&cli_set_tics);
-  
-       ast_cli_unregister(&cli_show_cls);
-       ast_cli_unregister(&cli_show_cl);
-       ast_cli_unregister(&cli_show_config);
-       ast_cli_unregister(&cli_show_port);
-       ast_cli_unregister(&cli_show_stacks);
-       ast_cli_unregister(&cli_restart_port);
-       ast_cli_unregister(&cli_port_up);
-       ast_cli_unregister(&cli_port_down);
-       ast_cli_unregister(&cli_set_debug);
-       ast_cli_unregister(&cli_set_crypt_debug);
-       ast_cli_unregister(&cli_reload);
-       /* ast_unregister_application("misdn_crypt"); */
-       ast_unregister_application("misdn_set_opt");
-       ast_unregister_application("misdn_facility");
-  
-       ast_channel_unregister(&misdn_tech);
-
-
-       free_robin_list();
-       misdn_cfg_destroy();
-       misdn_lib_destroy();
-  
-       if (misdn_debug)
-               free(misdn_debug);
-       if (misdn_debug_only)
-               free(misdn_debug_only);
-       
-       return 0;
-}
-
 int reload(void)
 {
        reload_config();
index 0be2be7..ee6f317 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster@digium.com>
  *
@@ -297,7 +297,7 @@ int unload_module(void)
        return __unload_module();
 }
 
-int load_module()
+int load_module(void)
 {
        /* Make sure we can register our channel type */
        if (ast_channel_register(&nbs_tech)) {
@@ -308,17 +308,17 @@ int load_module()
        return 0;
 }
 
-int usecount()
+int usecount(void)
 {
        return usecnt;
 }
 
-const char *description()
+const char *description(void)
 {
        return (char *) desc;
 }
 
-const char *key()
+const char *key(void)
 {
        return ASTERISK_GPL_KEY;
 }
index e408718..af55eda 100644 (file)
@@ -2773,6 +2773,72 @@ static float parse_gain_value(char *gain_type, char *value)
        return gain;
 }
 
+
+int unload_module()
+{
+       struct vpb_pvt *p;
+       /* First, take us out of the channel loop */
+       if (use_ast_ind == 1){
+               ast_channel_unregister(&vpb_tech_indicate);
+       }
+       else {
+               ast_channel_unregister(&vpb_tech);
+       }
+
+       ast_mutex_lock(&iflock); {
+               /* Hangup all interfaces if they have an owner */
+               p = iflist;
+               while(p) {
+                       if (p->owner)
+                               ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
+                       p = p->next;
+               }
+               iflist = NULL;
+       } ast_mutex_unlock(&iflock);
+
+       ast_mutex_lock(&monlock); {
+               if (mthreadactive > -1) {
+                       pthread_cancel(monitor_thread);
+                       pthread_join(monitor_thread, NULL);
+               }
+               mthreadactive = -2;
+       } ast_mutex_unlock(&monlock);
+
+       ast_mutex_lock(&iflock); {
+               /* Destroy all the interfaces and free their memory */
+
+               while(iflist) {
+                       p = iflist;                 
+                       ast_mutex_destroy(&p->lock);
+                       pthread_cancel(p->readthread);
+                       ast_mutex_destroy(&p->owner_lock);
+                       ast_mutex_destroy(&p->record_lock);
+                       ast_mutex_destroy(&p->play_lock);
+                       ast_mutex_destroy(&p->play_dtmf_lock);
+                       p->readthread = 0;
+
+                       vpb_close(p->handle);
+
+                       iflist = iflist->next;
+
+                       free(p);
+               }
+               iflist = NULL;
+       } ast_mutex_unlock(&iflock);
+
+       ast_mutex_lock(&bridge_lock); {
+               memset(bridges, 0, sizeof bridges);          
+       } ast_mutex_unlock(&bridge_lock);
+       ast_mutex_destroy(&bridge_lock);
+       for(int i = 0; i < max_bridges; i++ ) {
+               ast_mutex_destroy(&bridges[i].lock);
+               ast_cond_destroy(&bridges[i].cond);
+       }
+       free(bridges);
+
+       return 0;
+}
+
 int load_module()
 {
        struct ast_config *cfg;
@@ -2969,72 +3035,6 @@ int load_module()
        return error;
 }
 
-
-int unload_module()
-{
-       struct vpb_pvt *p;
-       /* First, take us out of the channel loop */
-       if (use_ast_ind == 1){
-               ast_channel_unregister(&vpb_tech_indicate);
-       }
-       else {
-               ast_channel_unregister(&vpb_tech);
-       }
-
-       ast_mutex_lock(&iflock); {
-               /* Hangup all interfaces if they have an owner */
-               p = iflist;
-               while(p) {
-                       if (p->owner)
-                               ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
-                       p = p->next;
-               }
-               iflist = NULL;
-       } ast_mutex_unlock(&iflock);
-
-       ast_mutex_lock(&monlock); {
-               if (mthreadactive > -1) {
-                       pthread_cancel(monitor_thread);
-                       pthread_join(monitor_thread, NULL);
-               }
-               mthreadactive = -2;
-       } ast_mutex_unlock(&monlock);
-
-       ast_mutex_lock(&iflock); {
-               /* Destroy all the interfaces and free their memory */
-
-               while(iflist) {
-                       p = iflist;                 
-                       ast_mutex_destroy(&p->lock);
-                       pthread_cancel(p->readthread);
-                       ast_mutex_destroy(&p->owner_lock);
-                       ast_mutex_destroy(&p->record_lock);
-                       ast_mutex_destroy(&p->play_lock);
-                       ast_mutex_destroy(&p->play_dtmf_lock);
-                       p->readthread = 0;
-
-                       vpb_close(p->handle);
-
-                       iflist = iflist->next;
-
-                       free(p);
-               }
-               iflist = NULL;
-       } ast_mutex_unlock(&iflock);
-
-       ast_mutex_lock(&bridge_lock); {
-               memset(bridges, 0, sizeof bridges);          
-       } ast_mutex_unlock(&bridge_lock);
-       ast_mutex_destroy(&bridge_lock);
-       for(int i = 0; i < max_bridges; i++ ) {
-               ast_mutex_destroy(&bridges[i].lock);
-               ast_cond_destroy(&bridges[i].cond);
-       }
-       free(bridges);
-
-       return 0;
-}
-
 int usecount()
 {
        return usecnt;