[asterisk-commits] irroot: branch irroot/distrotech-customers-10 r333488 - /team/irroot/distrote...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Aug 27 04:29:40 CDT 2011
Author: irroot
Date: Sat Aug 27 04:29:34 2011
New Revision: 333488
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=333488
Log:
Merged r331000 and r331037 From trunk
------------------------------------------------------------------------
r331037 | kmoore | 2011-08-08 22:28:20 +0200 (Mon, 08 Aug 2011) | 13 lines
Log queue member name when state_interface is set for ADDMEMBER and REMOVEMEMBER events
app_queue logs the events ADDMEMBER and REMOVEMEMBER with the agent field set
to the interface value rather than the membername value when a member is added
with a state_interface value set. However all other member related queue
events are logged with the membername when a state_interface is set. This
patch makes these fields optionally more consistent and correct.
(closes issue ASTERISK-14769)
Review: https://reviewboard.asterisk.org/r/1286
Patch-by: Jamuel Starkey
Tested-by: Kinsey Moore <kmoore at digium.com>
------------------------------------------------------------------------
r331000 | kmoore | 2011-08-08 17:00:26 +0200 (Mon, 08 Aug 2011) | 11 lines
app_queue: Add StateInterface to output of "queue show" and "QueueStatus"
This patch adds the state_interface of the queue member struct to the output
of "queue show" (CLI command) and "QueueStatus" (AMI action) when displaying
relevant queue member information. For the AMI event message the variable
StateInterface has been added.
(closes issue ASTERISK-18071)
Review: https://reviewboard.asterisk.org/r/1300/
Patch-by: Jamuel Starkey
------------------------------------------------------------------------
Modified:
team/irroot/distrotech-customers-10/apps/app_queue.c
Modified: team/irroot/distrotech-customers-10/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/apps/app_queue.c?view=diff&rev=333488&r1=333487&r2=333488
==============================================================================
--- team/irroot/distrotech-customers-10/apps/app_queue.c (original)
+++ team/irroot/distrotech-customers-10/apps/app_queue.c Sat Aug 27 04:29:34 2011
@@ -952,6 +952,9 @@
/*! \brief queues.conf [general] option */
static int negative_penalty_invalid = 0;
+/*! \brief queues.conf [general] option */
+static int log_membername_as_agent = 0;
+
enum queue_result {
QUEUE_UNKNOWN = 0,
QUEUE_TIMEOUT = 1,
@@ -1214,6 +1217,8 @@
static int set_member_paused(const char *queuename, const char *interface, const char *reason, int paused);
static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
+
+static struct member *find_member_by_queuename_and_interface(const char *queuename, const char *interface);
/*! \brief sets the QUEUESTATUS channel variable */
static void set_queue_result(struct ast_channel *chan, enum queue_result res)
{
@@ -1457,13 +1462,14 @@
"Queue: %s\r\n"
"Location: %s\r\n"
"MemberName: %s\r\n"
+ "StateInterface: %s\r\n"
"Membership: %s\r\n"
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
"LastCall: %d\r\n"
"Status: %d\r\n"
"Paused: %d\r\n",
- q->name, m->interface, m->membername, m->dynamic ? "dynamic" : m->realtime ? "realtime" : "static",
+ q->name, m->interface, m->membername, m->state_interface, m->dynamic ? "dynamic" : m->realtime ? "realtime" : "static",
m->penalty, m->calls, (int)m->lastcall, m->status, m->paused
);
@@ -2173,7 +2179,11 @@
m->realtime = 1;
m->ignorebusy = ignorebusy;
ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));
- ast_queue_log(q->name, "REALTIME", m->interface, "ADDMEMBER", "%s", "");
+ if (!log_membername_as_agent) {
+ ast_queue_log(q->name, "REALTIME", m->interface, "ADDMEMBER", "%s", "");
+ } else {
+ ast_queue_log(q->name, "REALTIME", m->membername, "ADDMEMBER", "%s", "");
+ }
ao2_link(q->members, m);
ao2_ref(m, -1);
m = NULL;
@@ -2354,7 +2364,11 @@
mem_iter = ao2_iterator_init(q->members, 0);
while ((m = ao2_iterator_next(&mem_iter))) {
if (m->dead) {
- ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", "");
+ if (ast_strlen_zero(m->membername) || !log_membername_as_agent) {
+ ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", "");
+ } else {
+ ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", "");
+ }
ao2_unlink(q->members, m);
q->membercount--;
}
@@ -2475,7 +2489,11 @@
mem_iter = ao2_iterator_init(q->members, 0);
while ((m = ao2_iterator_next(&mem_iter))) {
if (m->dead) {
- ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", "");
+ if (ast_strlen_zero(m->membername) || !log_membername_as_agent) {
+ ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", "");
+ } else {
+ ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", "");
+ }
ao2_unlink(q->members, m);
q->membercount--;
}
@@ -5347,13 +5365,14 @@
"Queue: %s\r\n"
"Location: %s\r\n"
"MemberName: %s\r\n"
+ "StateInterface: %s\r\n"
"Membership: %s\r\n"
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
"LastCall: %d\r\n"
"Status: %d\r\n"
"Paused: %d\r\n",
- q->name, new_member->interface, new_member->membername,
+ q->name, new_member->interface, new_member->membername, state_interface,
"dynamic",
new_member->penalty, new_member->calls, (int) new_member->lastcall,
new_member->status, new_member->paused);
@@ -5709,6 +5728,8 @@
{
int res=-1;
char *parse, *temppos = NULL;
+ struct member *mem = NULL;
+
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename);
AST_APP_ARG(interface);
@@ -5734,9 +5755,17 @@
ast_debug(1, "queue: %s, member: %s\n", args.queuename, args.interface);
+ if (log_membername_as_agent) {
+ mem = find_member_by_queuename_and_interface(args.queuename, args.interface);
+ }
+
switch (remove_from_queue(args.queuename, args.interface)) {
case RES_OKAY:
- ast_queue_log(args.queuename, chan->uniqueid, args.interface, "REMOVEMEMBER", "%s", "");
+ if (!mem || ast_strlen_zero(mem->membername) || !log_membername_as_agent) {
+ ast_queue_log(args.queuename, chan->uniqueid, args.interface, "REMOVEMEMBER", "%s", "");
+ } else {
+ ast_queue_log(args.queuename, chan->uniqueid, mem->membername, "REMOVEMEMBER", "%s", "");
+ }
ast_log(LOG_NOTICE, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "REMOVED");
res = 0;
@@ -5801,7 +5830,11 @@
switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface)) {
case RES_OKAY:
- ast_queue_log(args.queuename, chan->uniqueid, args.interface, "ADDMEMBER", "%s", "");
+ if (ast_strlen_zero(args.membername) || !log_membername_as_agent) {
+ ast_queue_log(args.queuename, chan->uniqueid, args.interface, "ADDMEMBER", "%s", "");
+ } else {
+ ast_queue_log(args.queuename, chan->uniqueid, args.membername, "ADDMEMBER", "%s", "");
+ }
ast_log(LOG_NOTICE, "Added interface '%s' to queue '%s'\n", args.interface, args.queuename);
pbx_builtin_setvar_helper(chan, "AQMSTATUS", "ADDED");
res = 0;
@@ -5817,7 +5850,7 @@
res = 0;
break;
case RES_OUTOFMEMORY:
- ast_log(LOG_ERROR, "Out of memory adding member %s to queue %s\n", args.interface, args.queuename);
+ ast_log(LOG_ERROR, "Out of memory adding interface %s to queue %s\n", args.interface, args.queuename);
break;
}
@@ -6731,6 +6764,9 @@
negative_penalty_invalid = 0;
if ((general_val = ast_variable_retrieve(cfg, "general", "negative_penalty_invalid")))
negative_penalty_invalid = ast_true(general_val);
+ log_membername_as_agent = 0;
+ if ((general_val = ast_variable_retrieve(cfg, "general", "log_membername_as_agent")))
+ log_membername_as_agent = ast_true(general_val);
}
/*! \brief reload information pertaining to a single member
@@ -7178,7 +7214,11 @@
while ((mem = ao2_iterator_next(&mem_iter))) {
ast_str_set(&out, 0, " %s", mem->membername);
if (strcasecmp(mem->membername, mem->interface)) {
- ast_str_append(&out, 0, " (%s)", mem->interface);
+ ast_str_append(&out, 0, " (%s", mem->interface);
+ if (mem->state_interface) {
+ ast_str_append(&out, 0, " from %s", mem->state_interface);
+ }
+ ast_str_append(&out, 0, ")");
}
if (mem->penalty)
ast_str_append(&out, 0, " with penalty %d", mem->penalty);
@@ -7446,6 +7486,7 @@
"Queue: %s\r\n"
"Name: %s\r\n"
"Location: %s\r\n"
+ "StateInterface: %s\r\n"
"Membership: %s\r\n"
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
@@ -7454,7 +7495,7 @@
"Paused: %d\r\n"
"%s"
"\r\n",
- q->name, mem->membername, mem->interface, mem->dynamic ? "dynamic" : "static",
+ q->name, mem->membername, mem->interface, mem->state_interface, mem->dynamic ? "dynamic" : "static",
mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText);
}
ao2_ref(mem, -1);
@@ -7530,7 +7571,11 @@
switch (add_to_queue(queuename, interface, membername, penalty, paused, queue_persistent_members, state_interface)) {
case RES_OKAY:
- ast_queue_log(queuename, "MANAGER", interface, "ADDMEMBER", "%s", "");
+ if (ast_strlen_zero(membername) || !log_membername_as_agent) {
+ ast_queue_log(queuename, "MANAGER", interface, "ADDMEMBER", "%s", "");
+ } else {
+ ast_queue_log(queuename, "MANAGER", membername, "ADDMEMBER", "%s", "");
+ }
astman_send_ack(s, m, "Added interface to queue");
break;
case RES_EXISTS:
@@ -7550,6 +7595,7 @@
static int manager_remove_queue_member(struct mansession *s, const struct message *m)
{
const char *queuename, *interface;
+ struct member *mem = NULL;
queuename = astman_get_header(m, "Queue");
interface = astman_get_header(m, "Interface");
@@ -7559,9 +7605,17 @@
return 0;
}
+ if (log_membername_as_agent) {
+ mem = find_member_by_queuename_and_interface(queuename, interface);
+ }
+
switch (remove_from_queue(queuename, interface)) {
case RES_OKAY:
- ast_queue_log(queuename, "MANAGER", interface, "REMOVEMEMBER", "%s", "");
+ if (!mem || ast_strlen_zero(mem->membername) || !log_membername_as_agent) {
+ ast_queue_log(queuename, "MANAGER", interface, "REMOVEMEMBER", "%s", "");
+ } else {
+ ast_queue_log(queuename, "MANAGER", mem->membername, "REMOVEMEMBER", "%s", "");
+ }
astman_send_ack(s, m, "Removed interface from queue");
break;
case RES_EXISTS:
@@ -7783,7 +7837,11 @@
switch (add_to_queue(queuename, interface, membername, penalty, 0, queue_persistent_members, state_interface)) {
case RES_OKAY:
- ast_queue_log(queuename, "CLI", interface, "ADDMEMBER", "%s", "");
+ if (ast_strlen_zero(membername) || !log_membername_as_agent) {
+ ast_queue_log(queuename, "CLI", interface, "ADDMEMBER", "%s", "");
+ } else {
+ ast_queue_log(queuename, "CLI", membername, "ADDMEMBER", "%s", "");
+ }
ast_cli(a->fd, "Added interface '%s' to queue '%s'\n", interface, queuename);
return CLI_SUCCESS;
case RES_EXISTS:
@@ -7851,11 +7909,12 @@
static char *handle_queue_remove_member(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
const char *queuename, *interface;
+ struct member *mem = NULL;
switch (cmd) {
case CLI_INIT:
e->command = "queue remove member";
- e->usage =
+ e->usage =
"Usage: queue remove member <channel> from <queue>\n"
" Remove a specific channel from a queue.\n";
return NULL;
@@ -7872,10 +7931,18 @@
queuename = a->argv[5];
interface = a->argv[3];
+ if (log_membername_as_agent) {
+ mem = find_member_by_queuename_and_interface(queuename, interface);
+ }
+
switch (remove_from_queue(queuename, interface)) {
case RES_OKAY:
- ast_queue_log(queuename, "CLI", interface, "REMOVEMEMBER", "%s", "");
- ast_cli(a->fd, "Removed interface '%s' from queue '%s'\n", interface, queuename);
+ if (!mem || ast_strlen_zero(mem->membername) || !log_membername_as_agent) {
+ ast_queue_log(queuename, "CLI", interface, "REMOVEMEMBER", "%s", "");
+ } else {
+ ast_queue_log(queuename, "CLI", mem->membername, "REMOVEMEMBER", "%s", "");
+ }
+ ast_cli(a->fd, "Removed interface %s from queue '%s'\n", interface, queuename);
return CLI_SUCCESS;
case RES_EXISTS:
ast_cli(a->fd, "Unable to remove interface '%s' from queue '%s': Not there\n", interface, queuename);
@@ -8598,6 +8665,23 @@
return 0;
}
+/* \brief Find a member by looking up queuename and interface.
+ * \return Returns a member or NULL if member not found.
+*/
+static struct member *find_member_by_queuename_and_interface(const char *queuename, const char *interface)
+{
+ struct member *mem = NULL;
+ struct call_queue *q;
+
+ if ((q = load_realtime_queue(queuename))) {
+ ao2_lock(q);
+ mem = ao2_find(q->members, interface, OBJ_KEY);
+ ao2_unlock(q);
+ queue_t_unref(q, "Expiring temporary reference.");
+ }
+ return mem;
+}
+
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "True Call Queueing",
.load = load_module,
.unload = unload_module,
More information about the asterisk-commits
mailing list