[asterisk-commits] trunk r20963 - in /trunk: cdr/ channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Apr 17 09:42:22 MST 2006


Author: kpfleming
Date: Mon Apr 17 11:42:21 2006
New Revision: 20963

URL: http://svn.digium.com/view/asterisk?rev=20963&view=rev
Log:
more module loader related fixes

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

Modified: trunk/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_pgsql.c?rev=20963&r1=20962&r2=20963&view=diff
==============================================================================
--- trunk/cdr/cdr_pgsql.c (original)
+++ trunk/cdr/cdr_pgsql.c Mon Apr 17 11:42:21 2006
@@ -176,7 +176,7 @@
 	return 0;
 }
 
-const char *description(void)
+static const char *description(void)
 {
 	return desc;
 }
@@ -326,34 +326,25 @@
 	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);

Modified: trunk/cdr/cdr_sqlite.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_sqlite.c?rev=20963&r1=20962&r2=20963&view=diff
==============================================================================
--- trunk/cdr/cdr_sqlite.c (original)
+++ trunk/cdr/cdr_sqlite.c Mon Apr 17 11:42:21 2006
@@ -164,12 +164,12 @@
 }
 
 
-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 @@
 	return 0;
 }
 
-int load_module(void)
+static int load_module(void *mod)
 {
 	char *zErr;
 	char fn[PATH_MAX];
@@ -218,17 +218,14 @@
 	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);

Modified: trunk/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_tds.c?rev=20963&r1=20962&r2=20963&view=diff
==============================================================================
--- trunk/cdr/cdr_tds.c (original)
+++ trunk/cdr/cdr_tds.c Mon Apr 17 11:42:21 2006
@@ -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 @@
 	}
 }
 
-const char *description(void)
+static const char *description(void)
 {
 	return desc;
 }
@@ -499,34 +499,25 @@
 	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);

Modified: trunk/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_alsa.c?rev=20963&r1=20962&r2=20963&view=diff
==============================================================================
--- trunk/channels/chan_alsa.c (original)
+++ trunk/channels/chan_alsa.c Mon Apr 17 11:42:21 2006
@@ -1042,7 +1042,7 @@
 	{ { "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 unload_module()
+int unload_module(void)
 {
 	int x;
 	
@@ -1125,17 +1125,17 @@
 	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;
 }

Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=20963&r1=20962&r2=20963&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Mon Apr 17 11:42:21 2006
@@ -3827,113 +3827,6 @@
 
 static int g_config_initialized=0;
 
-int load_module(void)
-{
-	int i;
-	
-	char ports[256]="";
-	
-	max_ports=misdn_lib_maxports_get();
-	
-	if (max_ports<=0) {
-		ast_log(LOG_ERROR, "Unable to initialize mISDN\n");
-		return -1;
-	}
-	
-	
-	misdn_cfg_init(max_ports);
-	g_config_initialized=1;
-	
-	misdn_debug = (int *)malloc(sizeof(int) * (max_ports+1));
-	misdn_cfg_get( 0, MISDN_GEN_DEBUG, &misdn_debug[0], sizeof(int));
-	for (i = 1; i <= max_ports; i++)
-		misdn_debug[i] = misdn_debug[0];
-	misdn_debug_only = (int *)calloc(max_ports + 1, sizeof(int));
-
-	
-	{
-		char tempbuf[BUFFERSIZE+1];
-		misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, tempbuf, BUFFERSIZE);
-		if (strlen(tempbuf))
-			tracing = 1;
-	}
-
-	ast_mutex_init(&cl_te_lock);
-	ast_mutex_init(&release_lock_mutex);
-
-
-	misdn_cfg_update_ptp();
-	misdn_cfg_get_ports_string(ports);
-		
-	if (strlen(ports))
-		chan_misdn_log(0, 0, "Got: %s from get_ports\n",ports);
-	
-	{
-		struct misdn_lib_iface iface = {
-			.cb_event = cb_events,
-			.cb_log = chan_misdn_log,
-			.cb_jb_empty = chan_misdn_jb_empty,
-		};
-		if (misdn_lib_init(ports, &iface, NULL))
-			chan_misdn_log(0, 0, "No te ports initialized\n");
-	}
-
-
-	{
-		if (ast_channel_register(&misdn_tech)) {
-			ast_log(LOG_ERROR, "Unable to register channel class %s\n", misdn_type);
-			unload_module();
-			return -1;
-		}
-	}
-  
-	ast_cli_register(&cli_send_display);
-	ast_cli_register(&cli_send_cd);
-	ast_cli_register(&cli_send_digit);
-	ast_cli_register(&cli_toggle_echocancel);
-	ast_cli_register(&cli_set_tics);
-
-	ast_cli_register(&cli_show_cls);
-	ast_cli_register(&cli_show_cl);
-	ast_cli_register(&cli_show_config);
-	ast_cli_register(&cli_show_port);
-	ast_cli_register(&cli_show_stacks);
-
-	ast_cli_register(&cli_restart_port);
-	ast_cli_register(&cli_port_up);
-	ast_cli_register(&cli_port_down);
-	ast_cli_register(&cli_set_debug);
-	ast_cli_register(&cli_set_crypt_debug);
-	ast_cli_register(&cli_reload);
-
-  
-	ast_register_application("misdn_set_opt", misdn_set_opt_exec, "misdn_set_flags",
-				 "misdn_set_opt(:<opt><optarg>:<opt><optarg>..):\n"
-				 "Sets mISDN opts. and optargs\n"
-				 "\n"
-		);
-
-	
-	ast_register_application("misdn_facility", misdn_facility_exec, "misdn_facility",
-				 "misdn_facility(<FACILITY_TYPE>|<ARG1>|..)\n"
-				 "Sends the Facility Message FACILITY_TYPE with \n"
-				 "the given Arguments to the current ISDN Channel\n"
-				 "Supported Facilities are:\n"
-				 "\n"
-				 "type=calldeflect args=Nr where to deflect\n"
-				 "\n"
-		);
-
-
-	misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
-	
-	chan_misdn_log(0, 0, "-- mISDN Channel Driver Registred -- (BE AWARE THIS DRIVER IS EXPERIMENTAL!)\n");
-
-	return 0;
-}
-
-
-
 int unload_module(void)
 {
 	/* First, take us out of the channel loop */
@@ -3978,6 +3871,113 @@
 	
 	return 0;
 }
+
+int load_module(void)
+{
+	int i;
+	
+	char ports[256]="";
+	
+	max_ports=misdn_lib_maxports_get();
+	
+	if (max_ports<=0) {
+		ast_log(LOG_ERROR, "Unable to initialize mISDN\n");
+		return -1;
+	}
+	
+	
+	misdn_cfg_init(max_ports);
+	g_config_initialized=1;
+	
+	misdn_debug = (int *)malloc(sizeof(int) * (max_ports+1));
+	misdn_cfg_get( 0, MISDN_GEN_DEBUG, &misdn_debug[0], sizeof(int));
+	for (i = 1; i <= max_ports; i++)
+		misdn_debug[i] = misdn_debug[0];
+	misdn_debug_only = (int *)calloc(max_ports + 1, sizeof(int));
+
+	
+	{
+		char tempbuf[BUFFERSIZE+1];
+		misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, tempbuf, BUFFERSIZE);
+		if (strlen(tempbuf))
+			tracing = 1;
+	}
+
+	ast_mutex_init(&cl_te_lock);
+	ast_mutex_init(&release_lock_mutex);
+
+
+	misdn_cfg_update_ptp();
+	misdn_cfg_get_ports_string(ports);
+		
+	if (strlen(ports))
+		chan_misdn_log(0, 0, "Got: %s from get_ports\n",ports);
+	
+	{
+		struct misdn_lib_iface iface = {
+			.cb_event = cb_events,
+			.cb_log = chan_misdn_log,
+			.cb_jb_empty = chan_misdn_jb_empty,
+		};
+		if (misdn_lib_init(ports, &iface, NULL))
+			chan_misdn_log(0, 0, "No te ports initialized\n");
+	}
+
+
+	{
+		if (ast_channel_register(&misdn_tech)) {
+			ast_log(LOG_ERROR, "Unable to register channel class %s\n", misdn_type);
+			unload_module();
+			return -1;
+		}
+	}
+  
+	ast_cli_register(&cli_send_display);
+	ast_cli_register(&cli_send_cd);
+	ast_cli_register(&cli_send_digit);
+	ast_cli_register(&cli_toggle_echocancel);
+	ast_cli_register(&cli_set_tics);
+
+	ast_cli_register(&cli_show_cls);
+	ast_cli_register(&cli_show_cl);
+	ast_cli_register(&cli_show_config);
+	ast_cli_register(&cli_show_port);
+	ast_cli_register(&cli_show_stacks);
+
+	ast_cli_register(&cli_restart_port);
+	ast_cli_register(&cli_port_up);
+	ast_cli_register(&cli_port_down);
+	ast_cli_register(&cli_set_debug);
+	ast_cli_register(&cli_set_crypt_debug);
+	ast_cli_register(&cli_reload);
+
+  
+	ast_register_application("misdn_set_opt", misdn_set_opt_exec, "misdn_set_flags",
+				 "misdn_set_opt(:<opt><optarg>:<opt><optarg>..):\n"
+				 "Sets mISDN opts. and optargs\n"
+				 "\n"
+		);
+
+	
+	ast_register_application("misdn_facility", misdn_facility_exec, "misdn_facility",
+				 "misdn_facility(<FACILITY_TYPE>|<ARG1>|..)\n"
+				 "Sends the Facility Message FACILITY_TYPE with \n"
+				 "the given Arguments to the current ISDN Channel\n"
+				 "Supported Facilities are:\n"
+				 "\n"
+				 "type=calldeflect args=Nr where to deflect\n"
+				 "\n"
+		);
+
+
+	misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
+	
+	chan_misdn_log(0, 0, "-- mISDN Channel Driver Registred -- (BE AWARE THIS DRIVER IS EXPERIMENTAL!)\n");
+
+	return 0;
+}
+
+
 
 int reload(void)
 {

Modified: trunk/channels/chan_nbs.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_nbs.c?rev=20963&r1=20962&r2=20963&view=diff
==============================================================================
--- trunk/channels/chan_nbs.c (original)
+++ trunk/channels/chan_nbs.c Mon Apr 17 11:42:21 2006
@@ -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 at digium.com>
  *
@@ -297,7 +297,7 @@
 	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 @@
 	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;
 }

Modified: trunk/channels/chan_vpb.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_vpb.c?rev=20963&r1=20962&r2=20963&view=diff
==============================================================================
--- trunk/channels/chan_vpb.c (original)
+++ trunk/channels/chan_vpb.c Mon Apr 17 11:42:21 2006
@@ -2771,6 +2771,72 @@
 	/*	return gain / (float)100; */
 
 	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()
@@ -2969,72 +3035,6 @@
 	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;



More information about the asterisk-commits mailing list