[asterisk-commits] mmichelson: branch mmichelson/issue13220 r182957 - /team/mmichelson/issue1322...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 18 13:42:33 CDT 2009
Author: mmichelson
Date: Wed Mar 18 13:42:30 2009
New Revision: 182957
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=182957
Log:
This commit contains the contents of garychen's patch on issue 13220.
I have taken some liberties with it, like renaming get_available_members
to num_available_members. I also played with the indentation level, too.
There's not much else to do here except 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=182957&r1=182956&r2=182957
==============================================================================
--- team/mmichelson/issue13220/apps/app_queue.c (original)
+++ team/mmichelson/issue13220/apps/app_queue.c Wed Mar 18 13:42:30 2009
@@ -1717,6 +1717,38 @@
}
}
+static int num_available_members(struct call_queue *q)
+{
+ struct member *mem;
+ int avl = 0;
+ struct ao2_iterator mem_iter;
+
+ ast_mutex_lock(&q->lock);
+
+ if (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) {
+ case AST_DEVICE_INUSE:
+ if (!q->ringinuse)
+ break;
+ /* else fall through */
+ case AST_DEVICE_NOT_INUSE:
+ case AST_DEVICE_UNKNOWN:
+ if (!mem->paused) {
+ avl++;
+ }
+ break;
+ }
+ ao2_ref(mem, -1);
+ }
+
+ ast_mutex_unlock(&q->lock);
+ return avl;
+}
/* traverse all defined queues which have calls waiting and contain this member
return 0 if no other queue has precedence (higher weight) or 1 if found */
@@ -1735,7 +1767,7 @@
if (q->count && q->members) {
if ((mem = ao2_find(q->members, member, OBJ_POINTER))) {
ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
- if (q->weight > rq->weight) {
+ if (q->weight > rq->weight && q->count >= num_available_members(q)) {
ast_log(LOG_DEBUG, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count);
found = 1;
}
More information about the asterisk-commits
mailing list