[svn-commits] mmichelson: branch mmichelson/issue13220 r183027 - /team/mmichelson/issue1322...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 18 15:43:48 CDT 2009


Author: mmichelson
Date: Wed Mar 18 15:43:34 2009
New Revision: 183027

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183027
Log:
Tweak the autofill and ringall behavior in num_available_members

This change makes it so that we don't always report that there is a member
available if there isn't really one available. Still, we will break out of the
loop as soon as we realize there is at least one member available since that's
really all we care about in this particular case.


Modified:
    team/mmichelson/issue13220/apps/app_queue.c

Modified: team/mmichelson/issue13220/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/issue13220/apps/app_queue.c?view=diff&rev=183027&r1=183026&r2=183027
==============================================================================
--- team/mmichelson/issue13220/apps/app_queue.c (original)
+++ team/mmichelson/issue13220/apps/app_queue.c Wed Mar 18 15:43:34 2009
@@ -1731,10 +1731,6 @@
 	int avl = 0;
 	struct ao2_iterator mem_iter;
 
-	if (!q->autofill || q->strategy == QUEUE_STRATEGY_RINGALL) {
-		ast_mutex_unlock(&q->lock);
-		return 1;
-	}
 	mem_iter = ao2_iterator_init(q->members, 0);
 	while ((mem = ao2_iterator_next(&mem_iter))) {
 		switch (mem->status) {
@@ -1750,6 +1746,20 @@
 			break;
 		}
 		ao2_ref(mem, -1);
+
+		/* If autofill is not enabled or if the queue's strategy is ringall, then
+		 * we really don't care about the number of available members so much as we
+		 * do that there is at least one available.
+		 *
+		 * In fact, we purposely will return from this function stating that only
+		 * one member is available if either of those conditions hold. That way,
+		 * functions which determine what action to take based on the number of available
+		 * members will operate properly. The reasoning is that even if multiple
+		 * members are available, only the head caller can actually be serviced.
+		 */
+		if ((!q->autofill || q->strategy == QUEUE_STRATEGY_RINGALL) && avl) {
+			break;
+		}
 	}
 
 	return avl;
@@ -2395,7 +2405,7 @@
 	ast_mutex_lock(&qe->parent->lock);
 
 	avl = num_available_members(qe->parent);
-		
+
 	ch = qe->parent->head;
 
 	if (option_debug) {
@@ -2420,7 +2430,7 @@
 			ast_log(LOG_DEBUG, "It's not our turn (%s).\n", qe->chan->name);
 		res = 0;
 	}
-	
+
 	return res;
 }
 /*! \brief The waiting areas for callers who are not actively calling members




More information about the svn-commits mailing list