[asterisk-commits] russell: branch russell/sla_updates r57008 - /team/russell/sla_updates/apps/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Feb 27 12:56:46 MST 2007


Author: russell
Date: Tue Feb 27 13:56:46 2007
New Revision: 57008

URL: http://svn.digium.com/view/asterisk?view=rev&rev=57008
Log:
Move the logic for choosing the highest priority idle trunk into a function.
Also, rename some functions to be more consistent.

Modified:
    team/russell/sla_updates/apps/app_meetme.c

Modified: team/russell/sla_updates/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/russell/sla_updates/apps/app_meetme.c?view=diff&rev=57008&r1=57007&r2=57008
==============================================================================
--- team/russell/sla_updates/apps/app_meetme.c (original)
+++ team/russell/sla_updates/apps/app_meetme.c Tue Feb 27 13:56:46 2007
@@ -3059,7 +3059,7 @@
 	return station;
 }
 
-static struct sla_trunk_ref *sla_sla_find_trunk_ref(const struct sla_station *station,
+static struct sla_trunk_ref *sla_find_trunk_ref(const struct sla_station *station,
 	const char *name)
 {
 	struct sla_trunk_ref *trunk_ref = NULL;
@@ -3499,6 +3499,20 @@
 	}
 }
 
+/*! \brief For a given station, choose the highest priority idle trunk
+ */
+static struct sla_trunk_ref *sla_choose_idle_trunk(const struct sla_station *station)
+{
+	struct sla_trunk_ref *trunk_ref = NULL;
+
+	AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) {
+		if (trunk_ref->state == SLA_TRUNK_STATE_IDLE)
+			break;
+	}
+
+	return trunk_ref;
+}
+
 /*! \brief Process trunk ring timeouts
  * \note Called with sla.lock locked
  * \return non-zero if a change to the ringing trunks was made
@@ -3788,7 +3802,7 @@
 	return NULL;
 }
 
-static int slastation_exec(struct ast_channel *chan, void *data)
+static int sla_station_exec(struct ast_channel *chan, void *data)
 {
 	char *station_name, *trunk_name;
 	struct sla_station *station;
@@ -3825,13 +3839,9 @@
 
 	AST_RWLIST_RDLOCK(&sla_trunks);
 	if (!ast_strlen_zero(trunk_name))
-		trunk_ref = sla_sla_find_trunk_ref(station, trunk_name);
-	else {
-		AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) {
-			if (trunk_ref->state == SLA_TRUNK_STATE_IDLE)
-				break;
-		}
-	}
+		trunk_ref = sla_find_trunk_ref(station, trunk_name);
+	else
+		trunk_ref = sla_choose_idle_trunk(station);
 	AST_RWLIST_UNLOCK(&sla_trunks);
 
 	if (ast_strlen_zero(trunk_name) && !trunk_ref) {
@@ -3934,7 +3944,7 @@
 	return ringing_trunk;
 }
 
-static int slatrunk_exec(struct ast_channel *chan, void *data)
+static int sla_trunk_exec(struct ast_channel *chan, void *data)
 {
 	const char *trunk_name = data;
 	char conf_name[MAX_CONFNUM];
@@ -4434,9 +4444,9 @@
 	res |= ast_register_application(app3, admin_exec, synopsis3, descrip3);
 	res |= ast_register_application(app2, count_exec, synopsis2, descrip2);
 	res |= ast_register_application(app, conf_exec, synopsis, descrip);
-	res |= ast_register_application(slastation_app, slastation_exec,
+	res |= ast_register_application(slastation_app, sla_station_exec,
 		slastation_synopsis, slastation_desc);
-	res |= ast_register_application(slatrunk_app, slatrunk_exec,
+	res |= ast_register_application(slatrunk_app, sla_trunk_exec,
 		slatrunk_synopsis, slatrunk_desc);
 
 	res |= ast_devstate_prov_add("Meetme", meetmestate);



More information about the asterisk-commits mailing list