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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 18 13:54:45 CDT 2009


Author: mmichelson
Date: Wed Mar 18 13:54:41 2009
New Revision: 182958

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=182958
Log:
Convert is_our_turn to use the new num_available_members function


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=182958&r1=182957&r2=182958
==============================================================================
--- team/mmichelson/issue13220/apps/app_queue.c (original)
+++ team/mmichelson/issue13220/apps/app_queue.c Wed Mar 18 13:54:41 2009
@@ -2369,6 +2369,7 @@
 
 	return peer;
 }
+
 /*! \brief Check if we should start attempting to call queue members
  *
  * The behavior of this function is dependent first on whether autofill is enabled
@@ -2381,9 +2382,6 @@
 static int is_our_turn(struct queue_ent *qe)
 {
 	struct queue_ent *ch;
-	struct member *cur;
-	int avl = 0;
-	int idx = 0;
 	int res;
 
 	if (!qe->parent->autofill) {
@@ -2401,41 +2399,24 @@
 		}	
 
 	} else {
+		int avl = num_available_members(qe->parent);
+		int idx = 0;
 		/* This needs a lock. How many members are available to be served? */
 		ast_mutex_lock(&qe->parent->lock);
 			
 		ch = qe->parent->head;
-	
-		if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "Even though there may be multiple members available, the strategy is ringall so only the head call is allowed in\n");
-			avl = 1;
-		} else {
-			struct ao2_iterator mem_iter = ao2_iterator_init(qe->parent->members, 0);
-			while ((cur = ao2_iterator_next(&mem_iter))) {
-				switch (cur->status) {
-				case AST_DEVICE_INUSE:
-					if (!qe->parent->ringinuse)
-						break;
-					/* else fall through */
-				case AST_DEVICE_NOT_INUSE:
-				case AST_DEVICE_UNKNOWN:
-					if (!cur->paused)
-						avl++;
-					break;
-				}
-				ao2_ref(cur, -1);
-			}
-		}
-
-		if (option_debug)
+
+		if (option_debug) {
 			ast_log(LOG_DEBUG, "There are %d available members.\n", avl);
+		}
 	
 		while ((idx < avl) && (ch) && (ch != qe)) {
 			if (!ch->pending)
 				idx++;
 			ch = ch->next;			
 		}
+
+		ast_mutex_unlock(&qe->parent->lock);
 	
 		/* If the queue entry is within avl [the number of available members] calls from the top ... */
 		if (ch && idx < avl) {
@@ -2448,7 +2429,6 @@
 			res = 0;
 		}
 		
-		ast_mutex_unlock(&qe->parent->lock);
 	}
 
 	return res;




More information about the svn-commits mailing list