[asterisk-commits] trunk r23272 - /trunk/channels/chan_h323.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 28 21:54:06 MST 2006


Author: rizzo
Date: Fri Apr 28 23:54:05 2006
New Revision: 23272

URL: http://svn.digium.com/view/asterisk?rev=23272&view=rev
Log:
partial adaptation to the new module loading
(not sure if it compiles, partly inspired by #9981 but
with adaptations)


Modified:
    trunk/channels/chan_h323.c

Modified: trunk/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_h323.c?rev=23272&r1=23271&r2=23272&view=diff
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Fri Apr 28 23:54:05 2006
@@ -180,10 +180,6 @@
 /** Protect the interface list (oh323_pvt) */
 AST_MUTEX_DEFINE_STATIC(iflock);
 
-/** Usage counter and associated lock */
-static int usecnt = 0;
-AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-
 /* Protect the monitoring thread, so only one process can kill or start it, and not
    when it's doing something critical. */
 AST_MUTEX_DEFINE_STATIC(monlock);
@@ -534,13 +530,8 @@
 	pvt->needdestroy = 1;
 
 	/* Update usage counter */
-	ast_mutex_lock(&usecnt_lock);
-	usecnt--;
-	if (usecnt < 0) {
-		ast_log(LOG_WARNING, "Usecnt < 0\n");
-	}
-	ast_mutex_unlock(&usecnt_lock);
 	ast_mutex_unlock(&pvt->lock);
+	ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
 	ast_update_use_count();
 	return 0;
 }
@@ -734,9 +725,7 @@
 	ast_mutex_unlock(&pvt->lock);
 	ch = ast_channel_alloc(1);
 	/* Update usage counter */
-	ast_mutex_lock(&usecnt_lock);
-	usecnt++;
-	ast_mutex_unlock(&usecnt_lock);
+	ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
 	ast_update_use_count();
 	ast_mutex_lock(&pvt->lock);
 	if (ch) {
@@ -2237,7 +2226,7 @@
 	return 0;
 }
 
-int reload(void)
+static int reload(void *mod)
 {
 	return h323_reload(0, 0, NULL);
 }
@@ -2317,7 +2306,7 @@
 	.set_rtp_peer=  oh323_set_rtp_peer,
 };
 
-int load_module()
+static int load_module(void *mod)
 {
 	int res;
 	ast_mutex_init(&userl.lock);
@@ -2385,7 +2374,7 @@
 	return res;
 }
 
-int unload_module() 
+static int unload_module(void *mod)
 {
 	struct oh323_pvt *p, *pl;
 
@@ -2459,18 +2448,14 @@
 	return 0; 
 } 
 
-int usecount()
-{
-	return usecnt;
-}
-
-const char *description()
-{
-	return (char *) desc;
-}
-
-const char *key()
+static const char *description(void)
+{
+	return desc;
+}
+
+static const char *key(void)
 {
 	return ASTERISK_GPL_KEY;
 }
 
+STD_MOD(MOD_1, reload, NULL, NULL);



More information about the asterisk-commits mailing list