Revert Janitor patch 341906 For now

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@341921 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Gregory Nietsky
2011-10-23 11:36:01 +00:00
parent 4f690341cf
commit 4037f1366d

View File

@@ -1423,7 +1423,7 @@ struct statechange {
}; };
/*! \brief set a member's status based on device state of that member's state_interface. /*! \brief set a member's status based on device state of that member's state_interface.
* *
* Lock interface list find sc, iterate through each queues queue_member list for member to * Lock interface list find sc, iterate through each queues queue_member list for member to
* update state inside queues * update state inside queues
*/ */
@@ -1601,24 +1601,21 @@ static int get_queue_member_status(struct member *cur)
static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused, const char *state_interface) static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused, const char *state_interface)
{ {
struct member *cur; struct member *cur;
if ((cur = ao2_alloc(sizeof(*cur), NULL))) { if ((cur = ao2_alloc(sizeof(*cur), NULL))) {
cur->penalty = penalty; cur->penalty = penalty;
cur->paused = paused; cur->paused = paused;
ast_copy_string(cur->interface, interface, sizeof(cur->interface)); ast_copy_string(cur->interface, interface, sizeof(cur->interface));
if (!ast_strlen_zero(state_interface)) { if (!ast_strlen_zero(state_interface))
ast_copy_string(cur->state_interface, state_interface, sizeof(cur->state_interface)); ast_copy_string(cur->state_interface, state_interface, sizeof(cur->state_interface));
} else { else
ast_copy_string(cur->state_interface, interface, sizeof(cur->state_interface)); ast_copy_string(cur->state_interface, interface, sizeof(cur->state_interface));
} if (!ast_strlen_zero(membername))
if (!ast_strlen_zero(membername)) {
ast_copy_string(cur->membername, membername, sizeof(cur->membername)); ast_copy_string(cur->membername, membername, sizeof(cur->membername));
} else { else
ast_copy_string(cur->membername, interface, sizeof(cur->membername)); ast_copy_string(cur->membername, interface, sizeof(cur->membername));
} if (!strchr(cur->interface, '/'))
if (!strchr(cur->interface, '/')) {
ast_log(LOG_WARNING, "No location at interface '%s'\n", interface); ast_log(LOG_WARNING, "No location at interface '%s'\n", interface);
}
if (!strncmp(cur->state_interface, "hint:", 5)) { if (!strncmp(cur->state_interface, "hint:", 5)) {
char *tmp = ast_strdupa(cur->state_interface), *context = tmp; char *tmp = ast_strdupa(cur->state_interface), *context = tmp;
char *exten = strsep(&context, "@") + 5; char *exten = strsep(&context, "@") + 5;
@@ -1661,7 +1658,7 @@ static int member_cmp_fn(void *obj1, void *obj2, int flags)
return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP; return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP;
} }
/*! /*!
* \brief Initialize Queue default values. * \brief Initialize Queue default values.
* \note the queue's lock must be held before executing this function * \note the queue's lock must be held before executing this function
*/ */
@@ -1761,14 +1758,14 @@ static void clear_queue(struct call_queue *q)
} }
} }
/*! /*!
* \brief Change queue penalty by adding rule. * \brief Change queue penalty by adding rule.
* *
* Check rule for errors with time or fomatting, see if rule is relative to rest * Check rule for errors with time or fomatting, see if rule is relative to rest
* of queue, iterate list of rules to find correct insertion point, insert and return. * of queue, iterate list of rules to find correct insertion point, insert and return.
* \retval -1 on failure * \retval -1 on failure
* \retval 0 on success * \retval 0 on success
* \note Call this with the rule_lists locked * \note Call this with the rule_lists locked
*/ */
static int insert_penaltychange(const char *list_name, const char *content, const int linenum) static int insert_penaltychange(const char *list_name, const char *content, const int linenum)
{ {
@@ -2105,9 +2102,8 @@ static void rt_handle_member_record(struct call_queue *q, char *interface, const
if (paused_str) { if (paused_str) {
paused = atoi(paused_str); paused = atoi(paused_str);
if (paused < 0) { if (paused < 0)
paused = 0; paused = 0;
}
} }
/* Find member by realtime uniqueid and update */ /* Find member by realtime uniqueid and update */
@@ -2116,9 +2112,8 @@ static void rt_handle_member_record(struct call_queue *q, char *interface, const
if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) { if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) {
m->dead = 0; /* Do not delete this one. */ m->dead = 0; /* Do not delete this one. */
ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid)); ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));
if (paused_str) { if (paused_str)
m->paused = paused; m->paused = paused;
}
if (strcasecmp(state_interface, m->state_interface)) { if (strcasecmp(state_interface, m->state_interface)) {
ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface)); ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface));
} }
@@ -2198,15 +2193,15 @@ static struct call_queue *alloc_queue(const char *queuename)
* Check for statically defined queue first, check if deleted RT queue, * Check for statically defined queue first, check if deleted RT queue,
* check for new RT queue, if queue vars are not defined init them with defaults. * check for new RT queue, if queue vars are not defined init them with defaults.
* reload RT queue vars, set RT queue members dead and reload them, return finished queue. * reload RT queue vars, set RT queue members dead and reload them, return finished queue.
* \retval the queue, * \retval the queue,
* \retval NULL if it doesn't exist. * \retval NULL if it doesn't exist.
* \note Should be called with the "queues" container locked. * \note Should be called with the "queues" container locked.
*/ */
static struct call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config) static struct call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
{ {
struct ast_variable *v; struct ast_variable *v;
struct call_queue *q, tmpq = { struct call_queue *q, tmpq = {
.name = queuename, .name = queuename,
}; };
struct member *m; struct member *m;
struct ao2_iterator mem_iter; struct ao2_iterator mem_iter;
@@ -2229,10 +2224,10 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
return q; return q;
} }
} }
} else if (!member_config) { } else if (!member_config)
/* Not found in the list, and it's not realtime ... */ /* Not found in the list, and it's not realtime ... */
return NULL; return NULL;
}
/* Check if queue is defined in realtime. */ /* Check if queue is defined in realtime. */
if (!queue_vars) { if (!queue_vars) {
/* Delete queue from in-core list if it has been deleted in realtime. */ /* Delete queue from in-core list if it has been deleted in realtime. */
@@ -2254,9 +2249,8 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
/* Create a new queue if an in-core entry does not exist yet. */ /* Create a new queue if an in-core entry does not exist yet. */
if (!q) { if (!q) {
struct ast_variable *tmpvar = NULL; struct ast_variable *tmpvar = NULL;
if (!(q = alloc_queue(queuename))) { if (!(q = alloc_queue(queuename)))
return NULL; return NULL;
}
ao2_lock(q); ao2_lock(q);
clear_queue(q); clear_queue(q);
q->realtime = 1; q->realtime = 1;
@@ -2276,9 +2270,8 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
} }
} }
/* We traversed all variables and didn't find a strategy */ /* We traversed all variables and didn't find a strategy */
if (!tmpvar) { if (!tmpvar)
q->strategy = QUEUE_STRATEGY_RINGALL; q->strategy = QUEUE_STRATEGY_RINGALL;
}
queues_t_link(queues, q, "Add queue to container"); queues_t_link(queues, q, "Add queue to container");
} }
init_queue(q); /* Ensure defaults for all parameters not set explicitly. */ init_queue(q); /* Ensure defaults for all parameters not set explicitly. */
@@ -2301,14 +2294,13 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
queue_set_param(q, tmp_name, v->value, -1, 0); queue_set_param(q, tmp_name, v->value, -1, 0);
} }
/* Temporarily set realtime members dead so we can detect deleted ones. /* Temporarily set realtime members dead so we can detect deleted ones.
* Also set the membercount correctly for realtime*/ * Also set the membercount correctly for realtime*/
mem_iter = ao2_iterator_init(q->members, 0); mem_iter = ao2_iterator_init(q->members, 0);
while ((m = ao2_iterator_next(&mem_iter))) { while ((m = ao2_iterator_next(&mem_iter))) {
q->membercount++; q->membercount++;
if (m->realtime) { if (m->realtime)
m->dead = 1; m->dead = 1;
}
ao2_ref(m, -1); ao2_ref(m, -1);
} }
ao2_iterator_destroy(&mem_iter); ao2_iterator_destroy(&mem_iter);
@@ -2345,7 +2337,7 @@ static struct call_queue *load_realtime_queue(const char *queuename)
struct ast_variable *queue_vars; struct ast_variable *queue_vars;
struct ast_config *member_config = NULL; struct ast_config *member_config = NULL;
struct call_queue *q = NULL, tmpq = { struct call_queue *q = NULL, tmpq = {
.name = queuename, .name = queuename,
}; };
int prev_weight = 0; int prev_weight = 0;
@@ -2466,9 +2458,9 @@ static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *
int pos = 0; int pos = 0;
int inserted = 0; int inserted = 0;
if (!(q = load_realtime_queue(queuename))) { if (!(q = load_realtime_queue(queuename)))
return res; return res;
}
ao2_lock(q); ao2_lock(q);
/* This is our one */ /* This is our one */
@@ -2777,9 +2769,8 @@ static void leave_queue(struct queue_ent *qe)
struct penalty_rule *pr_iter; struct penalty_rule *pr_iter;
int pos = 0; int pos = 0;
if (!(q = qe->parent)) { if (!(q = qe->parent))
return; return;
}
queue_t_ref(q, "Copy queue pointer from queue entry"); queue_t_ref(q, "Copy queue pointer from queue entry");
ao2_lock(q); ao2_lock(q);
@@ -2822,7 +2813,7 @@ static void leave_queue(struct queue_ent *qe)
} }
} }
if (q->dead) { if (q->dead) {
/* It's dead and nobody is in it, so kill it */ /* It's dead and nobody is in it, so kill it */
queues_t_unlink(queues, q, "Queue is now dead; remove it from the container"); queues_t_unlink(queues, q, "Queue is now dead; remove it from the container");
} }
@@ -3068,7 +3059,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
if (!tmp->chan) { /* If we can't, just go on to the next call */ if (!tmp->chan) { /* If we can't, just go on to the next call */
if (qe->chan->cdr) if (qe->chan->cdr)
ast_cdr_busy(qe->chan->cdr); ast_cdr_busy(qe->chan->cdr);
tmp->stillgoing = 0; tmp->stillgoing = 0;
ao2_lock(qe->parent); ao2_lock(qe->parent);
update_status(qe->parent, tmp->member, get_queue_member_status(tmp->member)); update_status(qe->parent, tmp->member, get_queue_member_status(tmp->member));
@@ -4018,8 +4009,8 @@ static int update_queue(struct call_queue *q, struct member *member, int callcom
struct member *mem; struct member *mem;
struct call_queue *qtmp; struct call_queue *qtmp;
struct ao2_iterator queue_iter; struct ao2_iterator queue_iter;
if (shared_lastcall) { if (shared_lastcall) {
queue_iter = ao2_iterator_init(queues, 0); queue_iter = ao2_iterator_init(queues, 0);
while ((qtmp = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { while ((qtmp = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
@@ -4293,7 +4284,7 @@ static void end_bridge_callback(void *data)
} }
/*! \brief A large function which calls members, updates statistics, and bridges the caller and a member /*! \brief A large function which calls members, updates statistics, and bridges the caller and a member
* *
* Here is the process of this function * Here is the process of this function
* 1. Process any options passed to the Queue() application. Options here mean the third argument to Queue() * 1. Process any options passed to the Queue() application. Options here mean the third argument to Queue()
* 2. Iterate trough the members of the queue, creating a callattempt corresponding to each member. During this * 2. Iterate trough the members of the queue, creating a callattempt corresponding to each member. During this
@@ -5122,9 +5113,9 @@ static struct member *interface_exists(struct call_queue *q, const char *interfa
struct member *mem; struct member *mem;
struct ao2_iterator mem_iter; struct ao2_iterator mem_iter;
if (!q) { if (!q)
return NULL; return NULL;
}
mem_iter = ao2_iterator_init(q->members, 0); mem_iter = ao2_iterator_init(q->members, 0);
while ((mem = ao2_iterator_next(&mem_iter))) { while ((mem = ao2_iterator_next(&mem_iter))) {
if (!strcasecmp(interface, mem->interface)) { if (!strcasecmp(interface, mem->interface)) {
@@ -5193,7 +5184,7 @@ static void dump_queue_members(struct call_queue *pm_queue)
static int remove_from_queue(const char *queuename, const char *interface) static int remove_from_queue(const char *queuename, const char *interface)
{ {
struct call_queue *q, tmpq = { struct call_queue *q, tmpq = {
.name = queuename, .name = queuename,
}; };
struct member *mem, tmpmem; struct member *mem, tmpmem;
int res = RES_NOSUCHQUEUE; int res = RES_NOSUCHQUEUE;
@@ -5247,9 +5238,8 @@ static int add_to_queue(const char *queuename, const char *interface, const char
/*! \note Ensure the appropriate realtime queue is loaded. Note that this /*! \note Ensure the appropriate realtime queue is loaded. Note that this
* short-circuits if the queue is already in memory. */ * short-circuits if the queue is already in memory. */
if (!(q = load_realtime_queue(queuename))) { if (!(q = load_realtime_queue(queuename)))
return res; return res;
}
ao2_lock(q); ao2_lock(q);
if ((old_member = interface_exists(q, interface)) == NULL) { if ((old_member = interface_exists(q, interface)) == NULL) {
@@ -5271,14 +5261,13 @@ static int add_to_queue(const char *queuename, const char *interface, const char
"dynamic", "dynamic",
new_member->penalty, new_member->calls, (int) new_member->lastcall, new_member->penalty, new_member->calls, (int) new_member->lastcall,
new_member->status, new_member->paused); new_member->status, new_member->paused);
ao2_ref(new_member, -1); ao2_ref(new_member, -1);
new_member = NULL; new_member = NULL;
if (dump) { if (dump)
dump_queue_members(q); dump_queue_members(q);
}
res = RES_OKAY; res = RES_OKAY;
} else { } else {
res = RES_OUTOFMEMORY; res = RES_OUTOFMEMORY;
@@ -5319,14 +5308,14 @@ static int set_member_paused(const char *queuename, const char *interface, const
if (mem->realtime) { if (mem->realtime) {
failed = update_realtime_member_field(mem, q->name, "paused", paused ? "1" : "0"); failed = update_realtime_member_field(mem, q->name, "paused", paused ? "1" : "0");
} }
if (failed) { if (failed) {
ast_log(LOG_WARNING, "Failed %spausing realtime queue member %s:%s\n", (paused ? "" : "un"), q->name, interface); ast_log(LOG_WARNING, "Failed %spausing realtime queue member %s:%s\n", (paused ? "" : "un"), q->name, interface);
ao2_ref(mem, -1); ao2_ref(mem, -1);
ao2_unlock(q); ao2_unlock(q);
queue_t_unref(q, "Done with iterator"); queue_t_unref(q, "Done with iterator");
continue; continue;
} }
found++; found++;
mem->paused = paused; mem->paused = paused;
@@ -5334,7 +5323,7 @@ static int set_member_paused(const char *queuename, const char *interface, const
dump_queue_members(q); dump_queue_members(q);
ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"), "%s", S_OR(reason, "")); ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"), "%s", S_OR(reason, ""));
if (!ast_strlen_zero(reason)) { if (!ast_strlen_zero(reason)) {
manager_event(EVENT_FLAG_AGENT, "QueueMemberPaused", manager_event(EVENT_FLAG_AGENT, "QueueMemberPaused",
"Queue: %s\r\n" "Queue: %s\r\n"
@@ -5354,13 +5343,13 @@ static int set_member_paused(const char *queuename, const char *interface, const
ao2_ref(mem, -1); ao2_ref(mem, -1);
} }
} }
if (!ast_strlen_zero(queuename) && !strcasecmp(queuename, q->name)) { if (!ast_strlen_zero(queuename) && !strcasecmp(queuename, q->name)) {
ao2_unlock(q); ao2_unlock(q);
queue_t_unref(q, "Done with iterator"); queue_t_unref(q, "Done with iterator");
break; break;
} }
ao2_unlock(q); ao2_unlock(q);
queue_t_unref(q, "Done with iterator"); queue_t_unref(q, "Done with iterator");
} }
@@ -5411,22 +5400,22 @@ static int set_member_penalty(const char *queuename, const char *interface, int
ast_log (LOG_ERROR, "Invalid queuename\n"); ast_log (LOG_ERROR, "Invalid queuename\n");
} else { } else {
ast_log (LOG_ERROR, "Invalid interface\n"); ast_log (LOG_ERROR, "Invalid interface\n");
} }
return RESULT_FAILURE; return RESULT_FAILURE;
} }
/* \brief Gets members penalty. /* \brief Gets members penalty.
* \return Return the members penalty or RESULT_FAILURE on error. * \return Return the members penalty or RESULT_FAILURE on error.
*/ */
static int get_member_penalty(char *queuename, char *interface) static int get_member_penalty(char *queuename, char *interface)
{ {
int foundqueue = 0, penalty; int foundqueue = 0, penalty;
struct call_queue *q, tmpq = { struct call_queue *q, tmpq = {
.name = queuename, .name = queuename,
}; };
struct member *mem; struct member *mem;
if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Search for queue"))) { if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Search for queue"))) {
foundqueue = 1; foundqueue = 1;
ao2_lock(q); ao2_lock(q);
@@ -5442,11 +5431,10 @@ static int get_member_penalty(char *queuename, char *interface)
} }
/* some useful debuging */ /* some useful debuging */
if (foundqueue) { if (foundqueue)
ast_log (LOG_ERROR, "Invalid queuename\n"); ast_log (LOG_ERROR, "Invalid queuename\n");
} else { else
ast_log (LOG_ERROR, "Invalid interface\n"); ast_log (LOG_ERROR, "Invalid interface\n");
}
return RESULT_FAILURE; return RESULT_FAILURE;
} }
@@ -5480,11 +5468,10 @@ static void reload_queue_members(void)
.name = queue_name, .name = queue_name,
}; };
cur_queue = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Reload queue members"); cur_queue = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Reload queue members");
} }
if (!cur_queue) { if (!cur_queue)
cur_queue = load_realtime_queue(queue_name); cur_queue = load_realtime_queue(queue_name);
}
if (!cur_queue) { if (!cur_queue) {
/* If the queue no longer exists, remove it from the /* If the queue no longer exists, remove it from the
@@ -5492,7 +5479,7 @@ static void reload_queue_members(void)
ast_log(LOG_WARNING, "Error loading persistent queue: '%s': it does not exist\n", queue_name); ast_log(LOG_WARNING, "Error loading persistent queue: '%s': it does not exist\n", queue_name);
ast_db_del(pm_family, queue_name); ast_db_del(pm_family, queue_name);
continue; continue;
} }
if (ast_db_get(pm_family, queue_name, queue_data, PM_MAX_LEN)) { if (ast_db_get(pm_family, queue_name, queue_data, PM_MAX_LEN)) {
queue_t_unref(cur_queue, "Expire reload reference"); queue_t_unref(cur_queue, "Expire reload reference");
@@ -6113,7 +6100,7 @@ static int queue_function_var(struct ast_channel *chan, const char *cmd, char *d
{ {
int res = -1; int res = -1;
struct call_queue *q, tmpq = { struct call_queue *q, tmpq = {
.name = data, .name = data,
}; };
char interfacevar[256] = ""; char interfacevar[256] = "";
@@ -6280,9 +6267,8 @@ static int queue_function_qac_dep(struct ast_channel *chan, const char *cmd, cha
ao2_iterator_destroy(&mem_iter); ao2_iterator_destroy(&mem_iter);
ao2_unlock(q); ao2_unlock(q);
queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER_COUNT"); queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER_COUNT");
} else { } else
ast_log(LOG_WARNING, "queue %s was not found\n", data); ast_log(LOG_WARNING, "queue %s was not found\n", data);
}
snprintf(buf, len, "%d", count); snprintf(buf, len, "%d", count);
@@ -6294,12 +6280,12 @@ static int queue_function_queuewaitingcount(struct ast_channel *chan, const char
{ {
int count = 0; int count = 0;
struct call_queue *q, tmpq = { struct call_queue *q, tmpq = {
.name = data, .name = data,
}; };
struct ast_variable *var = NULL; struct ast_variable *var = NULL;
buf[0] = '\0'; buf[0] = '\0';
if (ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "QUEUE_WAITING_COUNT requires an argument: queuename\n"); ast_log(LOG_ERROR, "QUEUE_WAITING_COUNT requires an argument: queuename\n");
return -1; return -1;
@@ -6312,7 +6298,7 @@ static int queue_function_queuewaitingcount(struct ast_channel *chan, const char
queue_t_unref(q, "Done with reference in QUEUE_WAITING_COUNT()"); queue_t_unref(q, "Done with reference in QUEUE_WAITING_COUNT()");
} else if ((var = ast_load_realtime("queues", "name", data, SENTINEL))) { } else if ((var = ast_load_realtime("queues", "name", data, SENTINEL))) {
/* if the queue is realtime but was not found in memory, this /* if the queue is realtime but was not found in memory, this
* means that the queue had been deleted from memory since it was * means that the queue had been deleted from memory since it was
* "dead." This means it has a 0 waiting count * "dead." This means it has a 0 waiting count
*/ */
count = 0; count = 0;
@@ -6329,7 +6315,7 @@ static int queue_function_queuewaitingcount(struct ast_channel *chan, const char
static int queue_function_queuememberlist(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) static int queue_function_queuememberlist(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{ {
struct call_queue *q, tmpq = { struct call_queue *q, tmpq = {
.name = data, .name = data,
}; };
struct member *m; struct member *m;
@@ -6927,9 +6913,8 @@ static char *__queues_show(struct mansession *s, int fd, int argc, const char *
struct ao2_iterator queue_iter; struct ao2_iterator queue_iter;
struct ao2_iterator mem_iter; struct ao2_iterator mem_iter;
if (argc != 2 && argc != 3) { if (argc != 2 && argc != 3)
return CLI_SHOWUSAGE; return CLI_SHOWUSAGE;
}
if (argc == 3) { /* specific queue */ if (argc == 3) { /* specific queue */
if ((q = load_realtime_queue(argv[2]))) { if ((q = load_realtime_queue(argv[2]))) {
@@ -6991,9 +6976,9 @@ static char *__queues_show(struct mansession *s, int fd, int argc, const char *
int2strat(q->strategy), q->holdtime, q->talktime, q->weight, int2strat(q->strategy), q->holdtime, q->talktime, q->weight,
q->callscompleted, q->callsabandoned,sl,q->servicelevel); q->callscompleted, q->callsabandoned,sl,q->servicelevel);
do_print(s, fd, ast_str_buffer(out)); do_print(s, fd, ast_str_buffer(out));
if (!ao2_container_count(q->members)) { if (!ao2_container_count(q->members))
do_print(s, fd, " No Members"); do_print(s, fd, " No Members");
} else { else {
struct member *mem; struct member *mem;
do_print(s, fd, " Members: "); do_print(s, fd, " Members: ");
@@ -7003,28 +6988,26 @@ static char *__queues_show(struct mansession *s, int fd, int argc, const char *
if (strcasecmp(mem->membername, mem->interface)) { if (strcasecmp(mem->membername, mem->interface)) {
ast_str_append(&out, 0, " (%s)", mem->interface); ast_str_append(&out, 0, " (%s)", mem->interface);
} }
if (mem->penalty) { if (mem->penalty)
ast_str_append(&out, 0, " with penalty %d", mem->penalty); ast_str_append(&out, 0, " with penalty %d", mem->penalty);
}
ast_str_append(&out, 0, "%s%s%s (%s)", ast_str_append(&out, 0, "%s%s%s (%s)",
mem->dynamic ? " (dynamic)" : "", mem->dynamic ? " (dynamic)" : "",
mem->realtime ? " (realtime)" : "", mem->realtime ? " (realtime)" : "",
mem->paused ? " (paused)" : "", mem->paused ? " (paused)" : "",
ast_devstate2str(mem->status)); ast_devstate2str(mem->status));
if (mem->calls) { if (mem->calls)
ast_str_append(&out, 0, " has taken %d calls (last was %ld secs ago)", ast_str_append(&out, 0, " has taken %d calls (last was %ld secs ago)",
mem->calls, (long) (time(NULL) - mem->lastcall)); mem->calls, (long) (time(NULL) - mem->lastcall));
} else { else
ast_str_append(&out, 0, " has taken no calls yet"); ast_str_append(&out, 0, " has taken no calls yet");
}
do_print(s, fd, ast_str_buffer(out)); do_print(s, fd, ast_str_buffer(out));
ao2_ref(mem, -1); ao2_ref(mem, -1);
} }
ao2_iterator_destroy(&mem_iter); ao2_iterator_destroy(&mem_iter);
} }
if (!q->head) { if (!q->head)
do_print(s, fd, " No Callers"); do_print(s, fd, " No Callers");
} else { else {
struct queue_ent *qe; struct queue_ent *qe;
int pos = 1; int pos = 1;
@@ -7043,11 +7026,10 @@ static char *__queues_show(struct mansession *s, int fd, int argc, const char *
ao2_iterator_destroy(&queue_iter); ao2_iterator_destroy(&queue_iter);
ao2_unlock(queues); ao2_unlock(queues);
if (!found) { if (!found) {
if (argc == 3) { if (argc == 3)
ast_str_set(&out, 0, "No such queue: %s.", argv[2]); ast_str_set(&out, 0, "No such queue: %s.", argv[2]);
} else { else
ast_str_set(&out, 0, "No queues."); ast_str_set(&out, 0, "No queues.");
}
do_print(s, fd, ast_str_buffer(out)); do_print(s, fd, ast_str_buffer(out));
} }
return CLI_SUCCESS; return CLI_SUCCESS;