[asterisk-commits] mmichelson: branch 1.4 r82252 - /branches/1.4/apps/app_queue.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 11 11:05:56 CDT 2007
Author: mmichelson
Date: Tue Sep 11 11:05:56 2007
New Revision: 82252
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82252
Log:
All instances of ao2_iterators which were just named 'i' have been renamed
to 'mem_iter' so that when refcounted queues are merged into trunk, there will be
little confusion regarding iterator names, especially when a queue and member iterator
are used in the same function.
Modified:
branches/1.4/apps/app_queue.c
Modified: branches/1.4/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_queue.c?view=diff&rev=82252&r1=82251&r2=82252
==============================================================================
--- branches/1.4/apps/app_queue.c (original)
+++ branches/1.4/apps/app_queue.c Tue Sep 11 11:05:56 2007
@@ -486,12 +486,12 @@
static enum queue_member_status get_member_status(struct call_queue *q, int max_penalty)
{
struct member *member;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
enum queue_member_status result = QUEUE_NO_MEMBERS;
ast_mutex_lock(&q->lock);
- i = ao2_iterator_init(q->members, 0);
- while ((member = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((member = ao2_iterator_next(&mem_iter))) {
if (max_penalty && (member->penalty > max_penalty)) {
ao2_ref(member, -1);
continue;
@@ -532,7 +532,7 @@
struct call_queue *q;
struct statechange *sc = data;
struct member *cur;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
struct member_interface *curint;
char *loc;
char *technology;
@@ -572,8 +572,8 @@
AST_LIST_LOCK(&queues);
AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
- i = ao2_iterator_init(q->members, 0);
- while ((cur = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((cur = ao2_iterator_next(&mem_iter))) {
char *interface;
char *slash_pos;
interface = ast_strdupa(cur->interface);
@@ -1022,9 +1022,9 @@
{
/* Free non-dynamic members */
struct member *cur;
- struct ao2_iterator i = ao2_iterator_init(q->members, 0);
-
- while ((cur = ao2_iterator_next(&i))) {
+ struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0);
+
+ while ((cur = ao2_iterator_next(&mem_iter))) {
if (all || !cur->dynamic) {
ao2_unlink(q->members, cur);
remove_from_interfaces(cur->interface);
@@ -1050,7 +1050,7 @@
struct ast_variable *v;
struct call_queue *q;
struct member *m;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
char *interface = NULL;
char *tmp, *tmp_name;
char tmpbuf[64]; /* Must be longer than the longest queue param name. */
@@ -1129,8 +1129,8 @@
/* Temporarily set realtime members dead so we can detect deleted ones.
* Also set the membercount correctly for realtime*/
- i = ao2_iterator_init(q->members, 0);
- while ((m = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((m = ao2_iterator_next(&mem_iter))) {
q->membercount++;
if (m->realtime)
m->dead = 1;
@@ -1145,8 +1145,8 @@
}
/* Delete all realtime members that have been deleted in DB. */
- i = ao2_iterator_init(q->members, 0);
- while ((m = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((m = ao2_iterator_next(&mem_iter))) {
if (m->dead) {
ao2_unlink(q->members, m);
ast_mutex_unlock(&q->lock);
@@ -1186,7 +1186,7 @@
struct ast_config *member_config = NULL;
struct member *m;
char *interface = NULL;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", q->name , NULL);
if (!member_config) {
@@ -1199,8 +1199,8 @@
ast_mutex_lock(&q->lock);
/* Temporarily set realtime members dead so we can detect deleted ones.*/
- i = ao2_iterator_init(q->members, 0);
- while ((m = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((m = ao2_iterator_next(&mem_iter))) {
if (m->realtime)
m->dead = 1;
ao2_ref(m, -1);
@@ -1214,8 +1214,8 @@
}
/* Delete all realtime members that have been deleted in DB. */
- i = ao2_iterator_init(q->members, 0);
- while ((m = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((m = ao2_iterator_next(&mem_iter))) {
if (m->dead) {
ao2_unlink(q->members, m);
ast_mutex_unlock(&q->lock);
@@ -1573,13 +1573,13 @@
static int update_status(struct call_queue *q, struct member *member, int status)
{
struct member *cur;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
/* Since a reload could have taken place, we have to traverse the list to
be sure it's still valid */
ast_mutex_lock(&q->lock);
- i = ao2_iterator_init(q->members, 0);
- while ((cur = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((cur = ao2_iterator_next(&mem_iter))) {
if (member != cur) {
ao2_ref(cur, -1);
continue;
@@ -2233,8 +2233,8 @@
ast_log(LOG_DEBUG, "Even though there are %d available members, the strategy is ringall so only the head call is allowed in\n", avl);
avl = 1;
} else {
- struct ao2_iterator i = ao2_iterator_init(qe->parent->members, 0);
- while ((cur = ao2_iterator_next(&i))) {
+ 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_NOT_INUSE:
case AST_DEVICE_UNKNOWN:
@@ -2826,13 +2826,13 @@
static struct member *interface_exists(struct call_queue *q, const char *interface)
{
struct member *mem;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
if (!q)
return NULL;
- i = ao2_iterator_init(q->members, 0);
- while ((mem = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((mem = ao2_iterator_next(&mem_iter))) {
if (!strcasecmp(interface, mem->interface))
return mem;
ao2_ref(mem, -1);
@@ -2853,15 +2853,15 @@
char value[PM_MAX_LEN];
int value_len = 0;
int res;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
memset(value, 0, sizeof(value));
if (!pm_queue)
return;
- i = ao2_iterator_init(pm_queue->members, 0);
- while ((cur_member = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(pm_queue->members, 0);
+ while ((cur_member = ao2_iterator_next(&mem_iter))) {
if (!cur_member->dynamic) {
ao2_ref(cur_member, -1);
continue;
@@ -3660,7 +3660,7 @@
struct call_queue *q;
struct ast_module_user *lu;
struct member *m;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
buf[0] = '\0';
@@ -3681,8 +3681,8 @@
AST_LIST_UNLOCK(&queues);
if (q) {
- i = ao2_iterator_init(q->members, 0);
- while ((m = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((m = ao2_iterator_next(&mem_iter))) {
/* Count the agents who are logged in and presently answering calls */
if ((m->status != AST_DEVICE_UNAVAILABLE) && (m->status != AST_DEVICE_INVALID)) {
count++;
@@ -3761,9 +3761,9 @@
if (q) {
int buflen = 0, count = 0;
- struct ao2_iterator i = ao2_iterator_init(q->members, 0);
-
- while ((m = ao2_iterator_next(&i))) {
+ struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0);
+
+ while ((m = ao2_iterator_next(&mem_iter))) {
/* strcat() is always faster than printf() */
if (count++) {
strncat(buf + buflen, ",", len - buflen - 1);
@@ -3834,7 +3834,7 @@
char *cat, *tmp;
struct ast_variable *var;
struct member *cur, *newm;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
int new;
const char *general_val = NULL;
char parse[80];
@@ -3894,8 +3894,8 @@
/* Re-initialize the queue, and clear statistics */
init_queue(q);
clear_queue(q);
- i = ao2_iterator_init(q->members, 0);
- while ((cur = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((cur = ao2_iterator_next(&mem_iter))) {
if (!cur->dynamic) {
cur->delme = 1;
}
@@ -3944,8 +3944,8 @@
}
/* Free remaining members marked as delme */
- i = ao2_iterator_init(q->members, 0);
- while ((cur = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((cur = ao2_iterator_next(&mem_iter))) {
if (! cur->delme) {
ao2_ref(cur, -1);
continue;
@@ -3977,8 +3977,8 @@
ast_log(LOG_DEBUG, "XXX Leaking a little memory :( XXX\n");
} else {
ast_mutex_lock(&q->lock);
- i = ao2_iterator_init(q->members, 0);
- while ((cur = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((cur = ao2_iterator_next(&mem_iter))) {
if (cur->dynamic)
q->membercount++;
cur->status = ast_device_state(cur->interface);
@@ -4004,7 +4004,7 @@
size_t max_left;
float sl = 0;
char *term = manager ? "\r\n" : "\n";
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
time(&now);
if (argc == 2)
@@ -4046,6 +4046,7 @@
continue;
}
}
+ ast_log(LOG_DEBUG, "MEMBERCOUNT is %d\n", q->membercount);
max_buf[0] = '\0';
max = max_buf;
max_left = sizeof(max_buf);
@@ -4068,8 +4069,8 @@
astman_append(s, " Members: %s", term);
else
ast_cli(fd, " Members: %s", term);
- i = ao2_iterator_init(q->members, 0);
- while ((mem = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((mem = ao2_iterator_next(&mem_iter))) {
max_buf[0] = '\0';
max = max_buf;
max_left = sizeof(max_buf);
@@ -4186,7 +4187,7 @@
struct queue_ent *qe;
float sl = 0;
struct member *mem;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
astman_send_ack(s, m, "Queue status will follow");
time(&now);
@@ -4215,8 +4216,8 @@
q->name, q->maxlen, q->count, q->holdtime, q->callscompleted,
q->callsabandoned, q->servicelevel, sl, q->weight, idText);
/* List Queue Members */
- i = ao2_iterator_init(q->members, 0);
- while ((mem = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((mem = ao2_iterator_next(&mem_iter))) {
if (ast_strlen_zero(memberfilter) || !strcmp(mem->interface, memberfilter)) {
astman_append(s, "Event: QueueMember\r\n"
"Queue: %s\r\n"
@@ -4497,7 +4498,7 @@
int which = 0;
struct call_queue *q;
struct member *m;
- struct ao2_iterator i;
+ struct ao2_iterator mem_iter;
/* 0 - queue; 1 - remove; 2 - member; 3 - <member>; 4 - from; 5 - <queue> */
if (pos > 5 || pos < 3)
@@ -4512,8 +4513,8 @@
if (!AST_LIST_EMPTY(&queues)) { /* XXX unnecessary ? the traverse does that for us */
AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
- i = ao2_iterator_init(q->members, 0);
- while ((m = ao2_iterator_next(&i))) {
+ mem_iter = ao2_iterator_init(q->members, 0);
+ while ((m = ao2_iterator_next(&mem_iter))) {
if (++which > state) {
char *tmp;
ast_mutex_unlock(&q->lock);
More information about the asterisk-commits
mailing list