[asterisk-commits] kmoore: trunk r331037 - in /trunk: apps/app_queue.c configs/queues.conf.sample
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 8 15:28:26 CDT 2011
Author: kmoore
Date: Mon Aug 8 15:28:20 2011
New Revision: 331037
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=331037
Log:
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>
Modified:
trunk/apps/app_queue.c
trunk/configs/queues.conf.sample
Modified: trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_queue.c?view=diff&rev=331037&r1=331036&r2=331037
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Mon Aug 8 15:28:20 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)
{
@@ -2169,7 +2174,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;
@@ -2350,7 +2359,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--;
}
@@ -2472,7 +2485,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--;
}
@@ -5685,6 +5702,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);
@@ -5710,9 +5729,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;
@@ -5777,7 +5804,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;
@@ -5793,7 +5824,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;
}
@@ -6707,6 +6738,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
@@ -7508,7 +7542,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:
@@ -7528,6 +7566,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");
@@ -7537,9 +7576,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:
@@ -7761,7 +7808,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:
@@ -7829,11 +7880,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;
@@ -7850,10 +7902,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);
@@ -8573,6 +8633,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,
Modified: trunk/configs/queues.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/queues.conf.sample?view=diff&rev=331037&r1=331036&r2=331037
==============================================================================
--- trunk/configs/queues.conf.sample (original)
+++ trunk/configs/queues.conf.sample Mon Aug 8 15:28:20 2011
@@ -64,6 +64,12 @@
; Negative_penalty_invalid will treat members with a negative penalty as logged off
;
;negative_penalty_invalid = no
+;
+; log_membername_as_agent will cause app_queue to log the membername rather than
+; the interface for the ADDMEMBER and REMOVEMEMBER events when a state_interface
+; is set. The default value (no) maintains backward compatibility.
+;
+;log_membername_as_agent = no
;
;[markq]
;
More information about the asterisk-commits
mailing list