[asterisk-commits] branch group/new_loader_completion r22328 - /team/group/new_loader_completion...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Apr 24 14:54:23 MST 2006


Author: kpfleming
Date: Mon Apr 24 16:54:22 2006
New Revision: 22328

URL: http://svn.digium.com/view/asterisk?rev=22328&view=rev
Log:
channel driver updates

Modified:
    team/group/new_loader_completion/channels/chan_agent.c
    team/group/new_loader_completion/channels/chan_alsa.c
    team/group/new_loader_completion/channels/chan_features.c
    team/group/new_loader_completion/channels/chan_iax2.c
    team/group/new_loader_completion/channels/chan_local.c
    team/group/new_loader_completion/channels/chan_mgcp.c
    team/group/new_loader_completion/channels/chan_misdn.c
    team/group/new_loader_completion/channels/chan_sip.c
    team/group/new_loader_completion/channels/chan_skinny.c
    team/group/new_loader_completion/channels/chan_zap.c

Modified: team/group/new_loader_completion/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_agent.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_agent.c (original)
+++ team/group/new_loader_completion/channels/chan_agent.c Mon Apr 24 16:54:22 2006
@@ -200,6 +200,7 @@
 	char loginchan[80];            /**< channel they logged in from */
 	char logincallerid[80];        /**< Caller ID they had when they logged in */
 	struct ast_channel *chan;      /**< Channel we use */
+	struct ast_module_user *u;	/*! reference to keep our module in memory while in use */
 	AST_LIST_ENTRY(agent_pvt) list;	/**< Next Agent in the linked list. */
 };
 
@@ -724,8 +725,7 @@
 	 * as in apps/app_chanisavail.c:chanavail_exec()
 	 */
 
-	ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
-	/* XXX do we need ast_update_use_count(); */
+	ast_module_user_remove(p->u);
 
 	ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
 	if (p->start && (ast->_state != AST_STATE_UP)) {
@@ -927,8 +927,7 @@
 		ast_setstate(tmp, state);
 		tmp->tech_pvt = p;
 		p->owner = tmp;
-		ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
-		ast_update_use_count();
+		p->u = ast_module_user_add(tmp);
 		tmp->priority = 1;
 		/* Wake up and wait for other applications (by definition the login app)
 		 * to release this channel). Takes ownership of the agent channel
@@ -1661,7 +1660,7 @@
 	int tries = 0;
 	int max_login_tries = maxlogintries;
 	struct agent_pvt *p;
-	struct localuser *u;
+	struct ast_module_user *u;
 	int login_state = 0;
 	char user[AST_MAX_AGENT] = "";
 	char pass[AST_MAX_AGENT];
@@ -1682,10 +1681,10 @@
 	char *filename = "agent-loginok";
 	char tmpchan[AST_MAX_BUF] = "";
 
-	LOCAL_USER_ADD(u);
+	u = ast_module_user_add(chan);
 
 	if (!(parse = ast_strdupa(data))) {
-		LOCAL_USER_REMOVE(u);
+		ast_module_user_remove(u);
 		return -1;
 	}
 
@@ -2050,7 +2049,7 @@
 
 	/* AgentLogin() exit */
 	if (!callbackmode) {
-		LOCAL_USER_REMOVE(u);
+		ast_module_user_remove(u);
 		return -1;
 	}
 	/* AgentCallbackLogin() exit*/
@@ -2070,7 +2069,7 @@
 			pbx_builtin_setvar_helper(chan, "AGENTSTATUS", "fail");
 		}
 		if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) {
-			LOCAL_USER_REMOVE(u);
+			ast_module_user_remove(u);
 			return 0;
 		}
 		/* Do we need to play agent-goodbye now that we will be hanging up? */
@@ -2085,7 +2084,7 @@
 		}
 	}
 
-	LOCAL_USER_REMOVE(u);
+	ast_module_user_remove(u);
 	
 	/* We should never get here if next priority exists when in callbackmode */
  	return -1;
@@ -2479,9 +2478,8 @@
  *
  * @returns int Always 0.
  */
-static int load_module(void *mod)
-{
-	__mod_desc = mod;
+static int load_module(void)
+{
 	/* Make sure we can register our agent channel type */
 	if (ast_channel_register(&agent_tech)) {
 		ast_log(LOG_ERROR, "Unable to register channel class 'Agent'\n");
@@ -2507,7 +2505,7 @@
 	return 0;
 }
 
-static int reload(void *mod)
+static int reload(void)
 {
 	read_agent_config();
 	if (persistent_agents)
@@ -2515,7 +2513,7 @@
 	return 0;
 }
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 	struct agent_pvt *p;
 	/* First, take us out of the channel loop */
@@ -2549,14 +2547,8 @@
 	return 0;
 }
 
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-static const char *description(void)
-{
-	return "Agent Proxy Channel";
-}
-
-STD_MOD(MOD_0, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "Agent Proxy Channel",
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+	       );

Modified: team/group/new_loader_completion/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_alsa.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_alsa.c (original)
+++ team/group/new_loader_completion/channels/chan_alsa.c Mon Apr 24 16:54:22 2006
@@ -109,7 +109,6 @@
 AST_MUTEX_DEFINE_STATIC(usecnt_lock);
 AST_MUTEX_DEFINE_STATIC(alsalock);
 
-static const char desc[] = "ALSA Console Channel Driver";
 static const char tdesc[] = "ALSA Console Channel Driver";
 static const char config[] = "alsa.conf";
 
@@ -1045,7 +1044,7 @@
 	{ { "autoanswer", NULL }, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete }
 };
 
-static int load_module(void *mod)
+static int load_module(void)
 {
 	int res;
 	int x;
@@ -1104,7 +1103,7 @@
 	return 0;
 }
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 	int x;
 	
@@ -1126,14 +1125,4 @@
 	return 0;
 }
 
-static const char *description(void)
-{
-	return (char *) desc;
-}
-
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_0, NULL, NULL, NULL);
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "ALSA Console Channel Driver");

Modified: team/group/new_loader_completion/channels/chan_features.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_features.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_features.c (original)
+++ team/group/new_loader_completion/channels/chan_features.c Mon Apr 24 16:54:22 2006
@@ -519,7 +519,7 @@
 	{ "feature", "show", "channels", NULL }, features_show, 
 	"Show status of feature channels", show_features_usage, NULL };
 
-static int load_module(void *mod)
+static int load_module(void)
 {
 	/* Make sure we can register our sip channel type */
 	if (ast_channel_register(&features_tech)) {
@@ -530,7 +530,7 @@
 	return 0;
 }
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 	struct feature_pvt *p;
 	
@@ -553,15 +553,5 @@
 	return 0;
 }
 
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-static const char *description(void)
-{
-	return "Feature Proxy Channel";
-}
-
-STD_MOD(MOD_1, NULL, NULL, NULL);
-
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Feature Proxy Channel");
+

Modified: team/group/new_loader_completion/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_iax2.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_iax2.c (original)
+++ team/group/new_loader_completion/channels/chan_iax2.c Mon Apr 24 16:54:22 2006
@@ -9336,7 +9336,7 @@
 	return reload_config();
 }
 
-static int reload(void *mod)
+static int reload(void)
 {
 	return reload_config();
 }
@@ -10032,7 +10032,7 @@
 	return 0;
 }
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 	ast_mutex_destroy(&iaxq.lock);
 	ast_mutex_destroy(&userl.lock);
@@ -10044,7 +10044,7 @@
 
 
 /*! \brief Load IAX2 module, load configuraiton ---*/
-static int load_module(void *mod)
+static int load_module(void)
 {
 	char *config = "iax.conf";
 	int res = 0;
@@ -10136,14 +10136,8 @@
 	return res;
 }
 
-static const char *description(void)
-{
-	return "Inter Asterisk eXchange (Ver 2)";
-}
-
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_1, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "Inter Asterisk eXchange (Ver 2)",
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+	       );

Modified: team/group/new_loader_completion/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_local.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_local.c (original)
+++ team/group/new_loader_completion/channels/chan_local.c Mon Apr 24 16:54:22 2006
@@ -106,6 +106,8 @@
 	int nooptimization;			/* Don't leave masq state */
 	struct ast_channel *owner;		/* Master Channel */
 	struct ast_channel *chan;		/* Outbound channel */
+	struct ast_module_user *u_owner;	/*! reference to keep the module loaded while in use */
+	struct ast_module_user *u_chan;		/*! reference to keep the module loaded while in use */
 	AST_LIST_ENTRY(local_pvt) list;		/* Next entity */
 };
 
@@ -387,11 +389,13 @@
 			pbx_builtin_setvar_helper(p->owner, "CHANLOCALSTATUS", status);
 		p->chan = NULL;
 		p->launchedpbx = 0;
-	} else
+		ast_module_user_remove(p->u_chan);
+	} else {
 		p->owner = NULL;
+		ast_module_user_remove(p->u_owner);
+	}
+	
 	ast->tech_pvt = NULL;
-	
-	ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
 	
 	if (!p->owner && !p->chan) {
 		/* Okay, done with the private part now, too. */
@@ -500,8 +504,8 @@
 	tmp2->tech_pvt = p;
 	p->owner = tmp;
 	p->chan = tmp2;
-	ast_atomic_fetchadd_int(&__mod_desc->usecnt, +2);	/* we allocate 2 new channels */
-	ast_update_use_count();
+	p->u_owner = ast_module_user_add(p->owner);
+	p->u_chan = ast_module_user_add(p->chan);
 	ast_copy_string(tmp->context, p->context, sizeof(tmp->context));
 	ast_copy_string(tmp2->context, p->context, sizeof(tmp2->context));
 	ast_copy_string(tmp2->exten, p->exten, sizeof(tmp->exten));
@@ -552,10 +556,8 @@
 	"Show status of local channels", show_locals_usage, NULL };
 
 /*! \brief Load module into PBX, register channel */
-static int load_module(void *mod)
-{
-	__mod_desc = mod;
-
+static int load_module(void)
+{
 	/* Make sure we can register our channel type */
 	if (ast_channel_register(&local_tech)) {
 		ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
@@ -566,7 +568,7 @@
 }
 
 /*! \brief Unload the local proxy channel from Asterisk */
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 	struct local_pvt *p;
 
@@ -588,14 +590,4 @@
 	return 0;
 }
 
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-static const char *description(void)
-{
-	return "Local Proxy Channel";
-}
-
-STD_MOD(MOD_1, NULL, NULL, NULL);
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Local Proxy Channel");

Modified: team/group/new_loader_completion/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_mgcp.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_mgcp.c (original)
+++ team/group/new_loader_completion/channels/chan_mgcp.c Mon Apr 24 16:54:22 2006
@@ -368,6 +368,7 @@
 	int messagepending;
 	struct mgcp_message *msgs;
 */
+	struct ast_module_user *u;	/*!< reference to keep the module alive while in use */
 	struct mgcp_subchannel *next; /* for out circular linked list */
 };
 
@@ -1053,10 +1054,7 @@
 		sub->rtp = NULL;
 	}
 
-	/* SC: Decrement use count */
-	ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
-	ast_update_use_count();
-	/* SC: Decrement use count */
+	ast_module_user_remove(sub->u);
 
 	if ((p->hookstate == MGCP_ONHOOK) && (!sub->next->rtp)) {
 		p->hidecallerid = 0;
@@ -1475,8 +1473,7 @@
 		if (i->amaflags)
 			tmp->amaflags = i->amaflags;
 		sub->owner = tmp;
-		ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
-		ast_update_use_count();
+		sub->u = ast_module_user_add(tmp);
 		tmp->callgroup = i->callgroup;
 		tmp->pickupgroup = i->pickupgroup;
 		ast_string_field_set(tmp, call_forward, i->call_forward);
@@ -4313,11 +4310,10 @@
 }
 
 /*! \brief  load_module: PBX load module - initialization ---*/
-static int load_module(void *mod)
+static int load_module(void)
 {
 	int res;
 
-	__mod_desc = mod;
 	sched = sched_context_create();
 	if (!sched) {
 		ast_log(LOG_WARNING, "Unable to create schedule context\n");
@@ -4368,13 +4364,13 @@
 	return 0;
 }
 
-static int reload(void *mod)
+static int reload(void)
 {
 	mgcp_reload(0, 0, NULL);
 	return 0;
 }
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 	struct mgcp_endpoint *e;
 	struct mgcp_gateway *g;
@@ -4446,14 +4442,8 @@
 	return 0;
 }
 
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-static const char *description(void)
-{
-	return "Media Gateway Control Protocol (MGCP)";
-}
-
-STD_MOD(MOD_1, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "Media Gateway Control Protocol (MGCP)",
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+	       );

Modified: team/group/new_loader_completion/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_misdn.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_misdn.c (original)
+++ team/group/new_loader_completion/channels/chan_misdn.c Mon Apr 24 16:54:22 2006
@@ -252,7 +252,6 @@
 
 /* #define MISDN_DEBUG 1 */
 
-static char *desc = "Channel driver for mISDN Support (Bri/Pri)";
 static const char misdn_type[] = "mISDN";
 
 static int tracing = 0 ;
@@ -3823,7 +3822,7 @@
 
 static int g_config_initialized=0;
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 	/* First, take us out of the channel loop */
 	ast_log(LOG_VERBOSE, "-- Unregistering mISDN Channel Driver --\n");
@@ -3868,7 +3867,7 @@
 	return 0;
 }
 
-static int load_module(void *mod)
+static int load_module(void)
 {
 	int i;
 	
@@ -3923,7 +3922,7 @@
 	{
 		if (ast_channel_register(&misdn_tech)) {
 			ast_log(LOG_ERROR, "Unable to register channel class %s\n", misdn_type);
-			unload_module(mod);
+			unload_module();
 			return -1;
 		}
 	}
@@ -3975,25 +3974,12 @@
 
 
 
-static int reload(void *mod)
+static int reload(void)
 {
 	reload_config();
 
 	return 0;
 }
-
-static const char *description(void)
-{
-	return desc;
-}
-
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-
-
 
 /*** SOME APPS ;)***/
 
@@ -4467,4 +4453,8 @@
 	}
 }
 
-STD_MOD(MOD_0, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "Channel driver for mISDN Support (Bri/Pri)",
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+	       );

Modified: team/group/new_loader_completion/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_sip.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_sip.c (original)
+++ team/group/new_loader_completion/channels/chan_sip.c Mon Apr 24 16:54:22 2006
@@ -202,7 +202,6 @@
 
 #define	INITIAL_CSEQ		101	/*!< our initial sip sequence number */
 
-static const char desc[] = "Session Initiation Protocol (SIP)";
 static const char config[] = "sip.conf";
 static const char notify_config[] = "sip_notify.conf";
 static int usecnt = 0;
@@ -13889,7 +13888,7 @@
 }
 
 /*! \brief  reload: Part of Asterisk module interface */
-static int reload(void *mod)
+static int reload(void)
 {
 	return sip_reload(0, 0, NULL);
 }
@@ -13925,7 +13924,7 @@
 };
 
 /*! \brief  load_module: PBX load module - initialization */
-static int load_module(void *mod)
+static int load_module(void)
 {
 	ASTOBJ_CONTAINER_INIT(&userl);	/* User object list */
 	ASTOBJ_CONTAINER_INIT(&peerl);	/* Peer object list */
@@ -13980,7 +13979,7 @@
 	return 0;
 }
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 	struct sip_pvt *p, *pl;
 	
@@ -14066,14 +14065,8 @@
 	return 0;
 }
 
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-static const char *description(void)
-{
-	return (char *) desc;
-}
-
-STD_MOD(MOD_1, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "Session Initiation Protocol (SIP)",
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+	       );

Modified: team/group/new_loader_completion/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_skinny.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_skinny.c (original)
+++ team/group/new_loader_completion/channels/chan_skinny.c Mon Apr 24 16:54:22 2006
@@ -3248,7 +3248,7 @@
 	ast_mutex_unlock(&devicelock);
 }
 
-static int reload(void *mod)
+static int reload(void)
 {
 	delete_devices();
 	reload_config();
@@ -3256,8 +3256,7 @@
 	return 0;
 }
 
-
-static int load_module(void *mod)
+static int load_module(void)
 {
 	int res = 0;
 
@@ -3294,7 +3293,7 @@
 	return res;
 }
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 #if 0
 	struct skinny_session *session, s;
@@ -3349,14 +3348,8 @@
 	return -1;
 }
 
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-static const char *description(void)
-{
-	return "Skinny Client Control Protocol (Skinny)";
-}
-
-STD_MOD(MOD_1, reload, NULL, NULL);
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "Skinny Client Control Protocol (Skinny)",
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+	       );

Modified: team/group/new_loader_completion/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/channels/chan_zap.c?rev=22328&r1=22327&r2=22328&view=diff
==============================================================================
--- team/group/new_loader_completion/channels/chan_zap.c (original)
+++ team/group/new_loader_completion/channels/chan_zap.c Mon Apr 24 16:54:22 2006
@@ -10428,7 +10428,7 @@
 	return 0;
 }
 
-static int unload_module(void *mod)
+static int unload_module(void)
 {
 #ifdef HAVE_LIBPRI		
 	int y;
@@ -11286,7 +11286,7 @@
 	return 0;
 }
 
-static int load_module(void *mod)
+static int load_module(void)
 {
 	int res;
 
@@ -11435,7 +11435,7 @@
 }
 
 
-static int reload(void *mod)
+static int reload(void)
 {
 	int res = 0;
 
@@ -11447,23 +11447,18 @@
 	return 0;
 }
 
-static const char *description(void)
-{
-	return "Zapata Telephony"
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT,
+		"Zapata Telephony"
 #ifdef ZAPATA_PRI
                " w/PRI"
 #endif
 #ifdef ZAPATA_R2
                " w/R2"
 #endif
-	;
-}
-
-static const char *key(void)
-{
-	return ASTERISK_GPL_KEY;
-}
-
-STD_MOD(MOD_1, reload, NULL, NULL);
-
-
+		,
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+	       );
+
+



More information about the asterisk-commits mailing list