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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Feb 28 11:01:24 MST 2007


Author: russell
Date: Wed Feb 28 12:01:23 2007
New Revision: 57057

URL: http://svn.digium.com/view/asterisk?view=rev&rev=57057
Log:
Fix station ring delays

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=57057&r1=57056&r2=57057
==============================================================================
--- team/russell/sla_updates/apps/app_meetme.c (original)
+++ team/russell/sla_updates/apps/app_meetme.c Wed Feb 28 12:01:23 2007
@@ -3103,8 +3103,6 @@
 	struct sla_station *station;
 	struct sla_trunk_ref *trunk_ref;
 
-	ast_log(LOG_DEBUG, "Setting all refs of trunk %s to state %s\n", trunk->name, trunkstate2str(state));
-
 	AST_LIST_TRAVERSE(&sla_stations, station, entry) {
 		AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) {
 			if (trunk_ref->trunk != trunk || (inactive_only ? trunk_ref->chan : 0))
@@ -3467,13 +3465,14 @@
 /*! \brief Calculate the ring delay for a given ringing trunk on a station
  * \param station the station
  * \param trunk the trunk.  If NULL, the highest priority ringing trunk will be used
- * \return the delay in seconds or UINT_MAX if there is no delay
+ * \return the number of ms left before the delay is complete, or INT_MAX if there is no delay
  */
 static int sla_check_station_delay(struct sla_station *station, 
 	struct sla_ringing_trunk *ringing_trunk)
 {
 	struct sla_trunk_ref *trunk_ref;
 	unsigned int delay = UINT_MAX;
+	int time_left, time_elapsed;
 
 	if (!ringing_trunk)
 		ringing_trunk = sla_choose_ringing_trunk(station, &trunk_ref, 0);
@@ -3489,8 +3488,13 @@
 	delay = trunk_ref->ring_delay;
 	if (!delay)
 		delay = station->ring_delay;
-
-	return delay;
+	if (!delay)
+		return INT_MAX;
+
+	time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_trunk->ring_begin);
+	time_left = (delay * 1000) - time_elapsed;
+
+	return time_left;
 }
 
 /*! \brief Ring stations based on current set of ringing trunks
@@ -3505,7 +3509,7 @@
 	 * trunks, is ringing. */
 	AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) {
 		AST_LIST_TRAVERSE(&ringing_trunk->trunk->stations, station_ref, entry) {
-			unsigned int delay;
+			int time_left;
 
 			/* Is this station already ringing? */
 			if (sla_check_ringing_station(station_ref->station))
@@ -3526,8 +3530,8 @@
 				continue;
 
 			/* Check for a ring delay in progress */
-			delay = sla_check_station_delay(station_ref->station, ringing_trunk);
-			if (delay != UINT_MAX && delay > 0)
+			time_left = sla_check_station_delay(station_ref->station, ringing_trunk);
+			if (time_left != INT_MAX && time_left > 0)
 				continue;
 
 			/* It is time to make this station begin to ring.  Do it! */
@@ -3718,8 +3722,7 @@
 
 	AST_LIST_TRAVERSE(&sla_stations, station, entry) {
 		struct sla_ringing_trunk *ringing_trunk;
-		unsigned int delay;
-		int time_left, time_elapsed;
+		int time_left;
 
 		/* Ignore stations already ringing */
 		if (sla_check_ringing_station(station))
@@ -3733,13 +3736,10 @@
 		if (!(ringing_trunk = sla_choose_ringing_trunk(station, NULL, 0)))
 			continue;
 
-		if ((delay = sla_check_station_delay(station, ringing_trunk)) == UINT_MAX)
+		if ((time_left = sla_check_station_delay(station, ringing_trunk)) == INT_MAX)
 			continue;
 
-		time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_trunk->ring_begin);
-		time_left = (delay * 1000) - time_elapsed;
-
-		/* If there is no time left, then the station needs to be answered.
+		/* If there is no time left, then the station needs to start ringing.
 		 * Return non-zero so that an event will be queued up an event to 
 		 * make that happen. */
 		if (time_left <= 0) {



More information about the asterisk-commits mailing list