[asterisk-commits] mmichelson: trunk r76804 - in /trunk: ./ apps/app_queue.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 24 11:42:37 CDT 2007
Author: mmichelson
Date: Tue Jul 24 11:42:36 2007
New Revision: 76804
URL: http://svn.digium.com/view/asterisk?view=rev&rev=76804
Log:
Merged revisions 76801 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r76801 | mmichelson | 2007-07-24 11:26:58 -0500 (Tue, 24 Jul 2007) | 13 lines
Added a membercount variable to call_queue struct which keeps track of the number of logged in members in a particular queue.
This makes it so that the 'n' option for Queue() can act properly depending on which strategy is used. If the strategy is
roundrobin, rrmemory, or ringall, we want to ring each phone once before moving on in the dialplan. However, if any other strategy is
used, we will only ring one phone since it cannot be guaranteed that a different phone will ring on subsequent attempts to ring a phone.
As a side effect of this, the QUEUE_MEMBER_COUNT dialplan function now just reads the membercount variable instead of traversing through
the member list to figure out how many members there are.
Special thanks to blitzrage for helping to test this out.
(closes issue #10127, reported by bcnit, patched by me, tested by blitzrage)
........
Modified:
trunk/ (props changed)
trunk/apps/app_queue.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=76804&r1=76803&r2=76804
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Tue Jul 24 11:42:36 2007
@@ -403,6 +403,7 @@
int autofill; /*!< Ignore the head call status and ring an available agent */
struct member *members; /*!< Head of the list of members */
+ int membercount; /*!< Number of members in queue */
struct queue_ent *head; /*!< Head of the list of callers */
AST_LIST_ENTRY(call_queue) list; /*!< Next call queue */
};
@@ -743,6 +744,7 @@
q->monfmt[0] = '\0';
q->periodicannouncefrequency = 0;
q->sound_callerannounce[0] = '\0'; /* Default, don't announce the caller that he has been answered */
+ q->membercount = 0;
ast_copy_string(q->sound_next, "queue-youarenext", sizeof(q->sound_next));
ast_copy_string(q->sound_thereare, "queue-thereare", sizeof(q->sound_thereare));
ast_copy_string(q->sound_calls, "queue-callswaiting", sizeof(q->sound_calls));
@@ -1052,6 +1054,7 @@
} else {
q->members = m;
}
+ q->membercount++;
}
} else {
m->dead = 0; /* Do not delete this one. */
@@ -1074,6 +1077,7 @@
else
q->members = next;
remove_from_interfaces(curm->interface);
+ q->membercount--;
ast_free(curm);
} else
prev = curm;
@@ -1168,8 +1172,9 @@
queue_set_param(q, tmp_name, v->value, -1, 0);
}
- /* Temporarily set non-dynamic members dead so we can detect deleted ones. */
- for (m = q->members; m; m = m->next) {
+ /* Temporarily set non-dynamic members dead so we can detect deleted ones.
+ * Also set the membercount correctly for realtime*/
+ for (m = q->members; m; m = m->next, q->membercount++) {
if (!m->dynamic)
m->dead = 1;
}
@@ -1193,6 +1198,7 @@
q->members = next_m;
}
remove_from_interfaces(m->interface);
+ q->membercount--;
ast_free(m);
} else {
prev_m = m;
@@ -2483,7 +2489,10 @@
ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT);
break;
case 'n':
- *go_on = 1;
+ if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY)
+ (*go_on)++;
+ else
+ *go_on = qe->parent->membercount;
break;
case 'i':
forwardsallowed = 0;
@@ -3001,10 +3010,12 @@
if ((last_member = interface_exists(q, interface))) {
if ((look = q->members) == last_member) {
q->members = last_member->next;
+ q->membercount--;
} else {
while (look != NULL) {
if (look->next == last_member) {
look->next = last_member->next;
+ q->membercount--;
break;
} else {
look = look->next;
@@ -3058,6 +3069,7 @@
new_member->dynamic = 1;
new_member->next = q->members;
q->members = new_member;
+ q->membercount++;
manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded",
"Queue: %s\r\n"
"Location: %s\r\n"
@@ -3587,7 +3599,7 @@
stat = get_member_status(qe.parent, qe.max_penalty);
/* exit after 'timeout' cycle if 'n' option enabled */
- if (go_on) {
+ if (go_on >= qe.parent->membercount) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Exiting on time-out cycle\n");
ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
@@ -3738,7 +3750,6 @@
{
int count = 0;
struct call_queue *q;
- struct member *m;
buf[0] = '\0';
@@ -3757,12 +3768,7 @@
AST_LIST_UNLOCK(&queues);
if (q) {
- for (m = q->members; m; m = m->next) {
- /* Count the agents who are logged in and presently answering calls */
- if ((m->status != AST_DEVICE_UNAVAILABLE) && (m->status != AST_DEVICE_INVALID)) {
- count++;
- }
- }
+ count = q->membercount;
ast_mutex_unlock(&q->lock);
} else
ast_log(LOG_WARNING, "queue %s was not found\n", data);
@@ -4019,6 +4025,7 @@
newm->next = q->members;
q->members = newm;
}
+ q->membercount++;
} else {
queue_set_param(q, var->name, var->value, var->lineno, 1);
}
@@ -4041,6 +4048,7 @@
q->members = next;
remove_from_interfaces(cur->interface);
+ q->membercount--;
ast_free(cur);
}
More information about the asterisk-commits
mailing list