[asterisk-commits] irroot: branch irroot/patches r336226 - /team/irroot/patches/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Sep 16 08:07:13 CDT 2011
Author: irroot
Date: Fri Sep 16 08:07:12 2011
New Revision: 336226
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=336226
Log:
Update patches
Undo discarded gwtimeout fix
Protect the CDR in app_queue by locking the channel
Remove mISDN round robin patch commited
Modified:
team/irroot/patches/distrotech-1.8.7.patch
team/irroot/patches/distrotech-1.8.patch
team/irroot/patches/distrotech-10.patch
team/irroot/patches/distrotech-trunk.patch
team/irroot/patches/t38gateway-trunk.patch
Modified: team/irroot/patches/distrotech-1.8.7.patch
URL: http://svnview.digium.com/svn/asterisk/team/irroot/patches/distrotech-1.8.7.patch?view=diff&rev=336226&r1=336225&r2=336226
==============================================================================
--- team/irroot/patches/distrotech-1.8.7.patch (original)
+++ team/irroot/patches/distrotech-1.8.7.patch Fri Sep 16 08:07:12 2011
@@ -1344,7 +1344,7 @@
} else {
ast_log(LOG_WARNING, "Asked to run MixMonitor on this call, but cannot find the MixMonitor app!\n");
}
-@@ -5009,8 +5075,26 @@
+@@ -5009,8 +5075,28 @@
qe->handled++;
ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "CONNECT", "%ld|%s|%ld", (long) time(NULL) - qe->start, peer->uniqueid,
(long)(orig - to > 0 ? (orig - to) / 1000 : 0));
@@ -1363,8 +1363,10 @@
+ if ((newcdr = ast_cdr_dup(cdr))) {
+ ast_cdr_init(newcdr, qe->chan);
+ ast_cdr_reset(newcdr, 0);
-+ cdr->next = newcdr;
++ ast_lock_channel(qe->chan);
++ cdr = ast_cdr_append(cdr, newcdr);
+ cdr = cdr->next;
++ ast_unlock_channel(qe->chan);
+ }
+ }
+ ast_copy_string(cdr->dstchannel, member->membername, sizeof(cdr->dstchannel));
@@ -1373,7 +1375,7 @@
if (qe->parent->eventwhencalled)
manager_event(EVENT_FLAG_AGENT, "AgentConnect",
"Queue: %s\r\n"
-@@ -5188,15 +5272,16 @@
+@@ -5188,15 +5274,16 @@
ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface));
if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Temporary reference for interface removal"))) {
@@ -1393,7 +1395,7 @@
return RES_NOT_DYNAMIC;
}
q->membercount--;
-@@ -5216,7 +5301,6 @@
+@@ -5216,7 +5303,6 @@
res = RES_EXISTS;
}
ao2_unlock(q);
@@ -1401,7 +1403,7 @@
queue_t_unref(q, "Expiring temporary reference");
}
-@@ -5241,8 +5325,6 @@
+@@ -5241,8 +5327,6 @@
if (!(q = load_realtime_queue(queuename)))
return res;
@@ -1410,7 +1412,7 @@
ao2_lock(q);
if ((old_member = interface_exists(q, interface)) == NULL) {
if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface))) {
-@@ -5253,13 +5335,14 @@
+@@ -5253,13 +5337,14 @@
"Queue: %s\r\n"
"Location: %s\r\n"
"MemberName: %s\r\n"
@@ -1426,7 +1428,7 @@
"dynamic",
new_member->penalty, new_member->calls, (int) new_member->lastcall,
new_member->status, new_member->paused);
-@@ -5279,7 +5362,6 @@
+@@ -5279,7 +5364,6 @@
res = RES_EXISTS;
}
ao2_unlock(q);
@@ -1434,7 +1436,7 @@
queue_t_unref(q, "Expiring temporary reference");
return res;
-@@ -5367,35 +5449,34 @@
+@@ -5367,35 +5451,34 @@
int foundinterface = 0, foundqueue = 0;
struct call_queue *q;
struct member *mem;
@@ -1487,7 +1489,7 @@
if (foundinterface) {
return RESULT_SUCCESS;
-@@ -5460,8 +5541,6 @@
+@@ -5460,8 +5543,6 @@
struct call_queue *cur_queue;
char queue_data[PM_MAX_LEN];
@@ -1496,7 +1498,7 @@
/* Each key in 'pm_family' is the name of a queue */
db_tree = ast_db_gettree(pm_family, NULL);
for (entry = db_tree; entry; entry = entry->next) {
-@@ -5532,7 +5611,6 @@
+@@ -5532,7 +5613,6 @@
queue_t_unref(cur_queue, "Expire reload reference");
}
@@ -1504,7 +1506,7 @@
if (db_tree) {
ast_log(LOG_NOTICE, "Queue members successfully reloaded from database.\n");
ast_db_freetree(db_tree);
-@@ -5616,6 +5694,8 @@
+@@ -5616,6 +5696,8 @@
{
int res=-1;
char *parse, *temppos = NULL;
@@ -1513,7 +1515,7 @@
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename);
AST_APP_ARG(interface);
-@@ -5641,9 +5721,17 @@
+@@ -5641,9 +5723,17 @@
ast_debug(1, "queue: %s, member: %s\n", args.queuename, args.interface);
@@ -1532,7 +1534,7 @@
ast_log(LOG_NOTICE, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "REMOVED");
res = 0;
-@@ -5708,7 +5796,11 @@
+@@ -5708,7 +5798,11 @@
switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface)) {
case RES_OKAY:
@@ -1545,7 +1547,7 @@
ast_log(LOG_NOTICE, "Added interface '%s' to queue '%s'\n", args.interface, args.queuename);
pbx_builtin_setvar_helper(chan, "AQMSTATUS", "ADDED");
res = 0;
-@@ -5724,7 +5816,7 @@
+@@ -5724,7 +5818,7 @@
res = 0;
break;
case RES_OUTOFMEMORY:
@@ -1554,7 +1556,7 @@
break;
}
-@@ -6168,31 +6260,37 @@
+@@ -6168,31 +6262,37 @@
return 0;
}
@@ -1602,7 +1604,7 @@
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 */
-@@ -6202,7 +6300,7 @@
+@@ -6202,7 +6302,7 @@
ao2_ref(m, -1);
}
ao2_iterator_destroy(&mem_iter);
@@ -1611,7 +1613,7 @@
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 */
-@@ -6212,7 +6310,7 @@
+@@ -6212,7 +6312,7 @@
ao2_ref(m, -1);
}
ao2_iterator_destroy(&mem_iter);
@@ -1620,7 +1622,7 @@
time_t now;
time(&now);
mem_iter = ao2_iterator_init(q->members, 0);
-@@ -6225,22 +6323,104 @@
+@@ -6225,22 +6325,104 @@
ao2_ref(m, -1);
}
ao2_iterator_destroy(&mem_iter);
@@ -1731,7 +1733,7 @@
*/
static int queue_function_qac_dep(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
-@@ -6446,7 +6626,8 @@
+@@ -6446,7 +6628,8 @@
static struct ast_custom_function queuemembercount_function = {
.name = "QUEUE_MEMBER",
@@ -1741,7 +1743,7 @@
};
static struct ast_custom_function queuemembercount_dep = {
-@@ -6529,8 +6710,9 @@
+@@ -6529,8 +6712,9 @@
{
const char *general_val = NULL;
queue_persistent_members = 0;
@@ -1752,7 +1754,7 @@
autofill_default = 0;
if ((general_val = ast_variable_retrieve(cfg, "general", "autofill")))
autofill_default = ast_true(general_val);
-@@ -6545,6 +6727,12 @@
+@@ -6545,6 +6729,12 @@
shared_lastcall = 0;
if ((general_val = ast_variable_retrieve(cfg, "general", "shared_lastcall")))
shared_lastcall = ast_true(general_val);
@@ -1765,7 +1767,7 @@
}
/*! \brief reload information pertaining to a single member
-@@ -6810,7 +6998,7 @@
+@@ -6810,7 +7000,7 @@
/* We've made it here, so it looks like we're doing operations on all queues. */
ao2_lock(queues);
@@ -1774,7 +1776,7 @@
/* Mark all queues as dead for the moment if we're reloading queues.
* For clarity, we could just be reloading members, in which case we don't want to mess
* with the other queue parameters at all*/
-@@ -6837,12 +7025,12 @@
+@@ -6837,12 +7027,12 @@
ao2_unlock(queues);
return 0;
}
@@ -1789,7 +1791,7 @@
* clear_queue function. If no queuename is passed in, then
* all queues will have their statistics reset.
*
-@@ -6992,7 +7180,11 @@
+@@ -6992,7 +7182,11 @@
while ((mem = ao2_iterator_next(&mem_iter))) {
ast_str_set(&out, 0, " %s", mem->membername);
if (strcasecmp(mem->membername, mem->interface)) {
@@ -1802,7 +1804,7 @@
}
if (mem->penalty)
ast_str_append(&out, 0, " with penalty %d", mem->penalty);
-@@ -7260,6 +7452,7 @@
+@@ -7260,6 +7454,7 @@
"Queue: %s\r\n"
"Name: %s\r\n"
"Location: %s\r\n"
@@ -1810,7 +1812,7 @@
"Membership: %s\r\n"
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
-@@ -7268,7 +7461,7 @@
+@@ -7268,7 +7463,7 @@
"Paused: %d\r\n"
"%s"
"\r\n",
@@ -1819,7 +1821,7 @@
mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText);
}
ao2_ref(mem, -1);
-@@ -7344,7 +7537,11 @@
+@@ -7344,7 +7539,11 @@
switch (add_to_queue(queuename, interface, membername, penalty, paused, queue_persistent_members, state_interface)) {
case RES_OKAY:
@@ -1832,7 +1834,7 @@
astman_send_ack(s, m, "Added interface to queue");
break;
case RES_EXISTS:
-@@ -7364,6 +7561,7 @@
+@@ -7364,6 +7563,7 @@
static int manager_remove_queue_member(struct mansession *s, const struct message *m)
{
const char *queuename, *interface;
@@ -1840,7 +1842,7 @@
queuename = astman_get_header(m, "Queue");
interface = astman_get_header(m, "Interface");
-@@ -7373,9 +7571,17 @@
+@@ -7373,9 +7573,17 @@
return 0;
}
@@ -1859,7 +1861,7 @@
astman_send_ack(s, m, "Removed interface from queue");
break;
case RES_EXISTS:
-@@ -7597,7 +7803,11 @@
+@@ -7597,7 +7805,11 @@
switch (add_to_queue(queuename, interface, membername, penalty, 0, queue_persistent_members, state_interface)) {
case RES_OKAY:
@@ -1872,7 +1874,7 @@
ast_cli(a->fd, "Added interface '%s' to queue '%s'\n", interface, queuename);
return CLI_SUCCESS;
case RES_EXISTS:
-@@ -7665,11 +7875,12 @@
+@@ -7665,11 +7877,12 @@
static char *handle_queue_remove_member(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
const char *queuename, *interface;
@@ -1886,7 +1888,7 @@
"Usage: queue remove member <channel> from <queue>\n"
" Remove a specific channel from a queue.\n";
return NULL;
-@@ -7686,10 +7897,18 @@
+@@ -7686,10 +7899,18 @@
queuename = a->argv[5];
interface = a->argv[3];
@@ -1907,7 +1909,7 @@
return CLI_SUCCESS;
case RES_EXISTS:
ast_cli(a->fd, "Unable to remove interface '%s' from queue '%s': Not there\n", interface, queuename);
-@@ -8412,6 +8631,26 @@
+@@ -8412,6 +8633,26 @@
return 0;
}
Modified: team/irroot/patches/distrotech-1.8.patch
URL: http://svnview.digium.com/svn/asterisk/team/irroot/patches/distrotech-1.8.patch?view=diff&rev=336226&r1=336225&r2=336226
==============================================================================
--- team/irroot/patches/distrotech-1.8.patch (original)
+++ team/irroot/patches/distrotech-1.8.patch Fri Sep 16 08:07:12 2011
@@ -1,7 +1,7 @@
Index: channels/chan_sip.c
===================================================================
---- channels/chan_sip.c (.../branches/1.8) (revision 336160)
-+++ channels/chan_sip.c (.../team/irroot/distrotech-customers-1.8) (revision 336160)
+--- channels/chan_sip.c (.../branches/1.8) (revision 336225)
++++ channels/chan_sip.c (.../team/irroot/distrotech-customers-1.8) (revision 336225)
@@ -4316,6 +4316,9 @@
case T38_ENABLED:
state = T38_STATE_NEGOTIATED;
@@ -403,125 +403,10 @@
return FALSE;
}
-Index: channels/chan_misdn.c
-===================================================================
---- channels/chan_misdn.c (.../branches/1.8) (revision 336160)
-+++ channels/chan_misdn.c (.../team/irroot/distrotech-customers-1.8) (revision 336160)
-@@ -7884,64 +7884,63 @@
- }
-
- if (rr) {
-- int robin_channel = rr->channel;
- int port_start;
-- int next_chan = 1;
-+ int bchan_start;
-+ int port_up;
-+ int check;
-+ int maxbchans;
-
-- do {
-- port_start = 0;
-- for (port = misdn_cfg_get_next_port_spin(rr->port); port > 0 && port != port_start;
-- port = misdn_cfg_get_next_port_spin(port)) {
-+ if (!rr->port) {
-+ rr->port = misdn_cfg_get_next_port_spin(0);
-+ }
-
-- if (!port_start) {
-- port_start = port;
-- }
-+ if (!rr->channel) {
-+ rr->channel = 1;
-+ }
-
-- if (port >= port_start) {
-- next_chan = 1;
-- }
-+ bchan_start = rr->channel;
-+ port_start = rr->port;
-+ do {
-+ misdn_cfg_get(rr->port, MISDN_CFG_GROUPNAME, cfg_group, sizeof(cfg_group));
-+ if (strcasecmp(cfg_group, group)) {
-+ rr->port = misdn_cfg_get_next_port_spin(rr->port);
-+ rr->channel = 1;
-+ continue;
-+ }
-
-- if (port <= port_start && next_chan) {
-- int maxbchans = misdn_lib_get_maxchans(port);
-+ misdn_cfg_get(rr->port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(check));
-+ port_up = misdn_lib_port_up(rr->port, check);
-
-- if (++robin_channel >= maxbchans) {
-- robin_channel = 1;
-- }
-- next_chan = 0;
-- }
-+ if (!port_up) {
-+ chan_misdn_log(1, rr->port, "L1 is not Up on this Port\n");
-+ rr->port = misdn_cfg_get_next_port_spin(rr->port);
-+ rr->channel = 1;
-+ } else if (port_up < 0) {
-+ ast_log(LOG_WARNING, "This port (%d) is blocked\n", rr->port);
-+ rr->port = misdn_cfg_get_next_port_spin(rr->port);
-+ rr->channel = 1;
-+ } else {
-+ chan_misdn_log(4, rr->port, "portup\n");
-+ maxbchans = misdn_lib_get_maxchans(rr->port);
-
-- misdn_cfg_get(port, MISDN_CFG_GROUPNAME, cfg_group, sizeof(cfg_group));
-+ for (;rr->channel <= maxbchans;rr->channel++) {
-+ chan_misdn_log(4, rr->port, "Checking channel %d\n", rr->channel);
-
-- if (!strcasecmp(cfg_group, group)) {
-- int port_up;
-- int check;
--
-- misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(check));
-- port_up = misdn_lib_port_up(port, check);
--
-- if (check && !port_up) {
-- chan_misdn_log(1, port, "L1 is not Up on this Port\n");
-+ if ((newbc = misdn_lib_get_free_bc(rr->port, rr->channel, 0, 0))) {
-+ chan_misdn_log(4, rr->port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
-+ rr->channel++;
-+ break;
- }
--
-- if (check && port_up < 0) {
-- ast_log(LOG_WARNING, "This port (%d) is blocked\n", port);
-- }
--
-- if (port_up > 0) {
-- newbc = misdn_lib_get_free_bc(port, robin_channel, 0, 0);
-- if (newbc) {
-- chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
-- if (port_up) {
-- chan_misdn_log(4, port, "portup:%d\n", port_up);
-- }
-- rr->port = newbc->port;
-- rr->channel = newbc->channel;
-- break;
-- }
-- }
- }
-+ if (!newbc || (rr->channel > maxbchans)) {
-+ rr->port = misdn_cfg_get_next_port_spin(rr->port);
-+ rr->channel = 1;
-+ }
-+
- }
-- } while (!newbc && robin_channel != rr->channel);
-+ } while (!newbc && (rr->port > 0) &&
-+ ((rr->port != port_start) || ((rr->port == port_start) && (rr->channel < bchan_start))));
-+
- } else {
- for (port = misdn_cfg_get_next_port(0); port > 0;
- port = misdn_cfg_get_next_port(port)) {
Index: channels/sip/include/sip.h
===================================================================
---- channels/sip/include/sip.h (.../branches/1.8) (revision 336160)
-+++ channels/sip/include/sip.h (.../team/irroot/distrotech-customers-1.8) (revision 336160)
+--- channels/sip/include/sip.h (.../branches/1.8) (revision 336225)
++++ channels/sip/include/sip.h (.../team/irroot/distrotech-customers-1.8) (revision 336225)
@@ -352,9 +352,11 @@
@@ -555,8 +440,8 @@
Index: channels/sip/include/sdp_crypto.h
===================================================================
---- channels/sip/include/sdp_crypto.h (.../branches/1.8) (revision 336160)
-+++ channels/sip/include/sdp_crypto.h (.../team/irroot/distrotech-customers-1.8) (revision 336160)
+--- channels/sip/include/sdp_crypto.h (.../branches/1.8) (revision 336225)
++++ channels/sip/include/sdp_crypto.h (.../team/irroot/distrotech-customers-1.8) (revision 336225)
@@ -31,6 +31,7 @@
#include <asterisk/rtp_engine.h>
@@ -590,8 +475,8 @@
/*! \brief Return the a_crypto value of the sdp_crypto struct
Index: channels/sip/include/srtp.h
===================================================================
---- channels/sip/include/srtp.h (.../branches/1.8) (revision 336160)
-+++ channels/sip/include/srtp.h (.../team/irroot/distrotech-customers-1.8) (revision 336160)
+--- channels/sip/include/srtp.h (.../branches/1.8) (revision 336225)
++++ channels/sip/include/srtp.h (.../team/irroot/distrotech-customers-1.8) (revision 336225)
@@ -34,6 +34,8 @@
#define SRTP_ENCR_OPTIONAL (1 << 1) /* SRTP encryption optional */
#define SRTP_CRYPTO_ENABLE (1 << 2)
@@ -603,8 +488,8 @@
struct sip_srtp {
Index: channels/sip/sdp_crypto.c
===================================================================
---- channels/sip/sdp_crypto.c (.../branches/1.8) (revision 336160)
-+++ channels/sip/sdp_crypto.c (.../team/irroot/distrotech-customers-1.8) (revision 336160)
+--- channels/sip/sdp_crypto.c (.../branches/1.8) (revision 336225)
++++ channels/sip/sdp_crypto.c (.../team/irroot/distrotech-customers-1.8) (revision 336225)
@@ -32,6 +32,7 @@
#include "asterisk/options.h"
#include "asterisk/utils.h"
@@ -655,8 +540,8 @@
Index: channels/chan_local.c
===================================================================
---- channels/chan_local.c (.../branches/1.8) (revision 336160)
-+++ channels/chan_local.c (.../team/irroot/distrotech-customers-1.8) (revision 336160)
+--- channels/chan_local.c (.../branches/1.8) (revision 336225)
++++ channels/chan_local.c (.../team/irroot/distrotech-customers-1.8) (revision 336225)
@@ -588,6 +588,7 @@
static int local_write(struct ast_channel *ast, struct ast_frame *f)
{
@@ -686,4567 +571,3 @@
}
if (!ast_test_flag(p, LOCAL_ALREADY_MASQED)) {
-Index: configure.ac
-===================================================================
---- configure.ac (.../branches/1.8) (revision 336160)
-+++ configure.ac (.../team/irroot/distrotech-customers-1.8) (revision 336160)
-@@ -1698,7 +1698,7 @@
- AST_EXT_LIB_CHECK([SUPPSERV], [suppserv], [encodeFac], [mISDNuser/suppserv.h])
- AST_C_DEFINE_CHECK([MISDN_FAC_RESULT], [Fac_RESULT], [mISDNuser/suppserv.h])
- AST_C_DEFINE_CHECK([MISDN_FAC_ERROR], [Fac_ERROR], [mISDNuser/suppserv.h])
-- AC_CHECK_HEADER([linux/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])])
-+ AC_CHECK_HEADER([mISDN/mISDNdsp.h], [AC_DEFINE_UNQUOTED([MISDN_1_2], 1, [Build chan_misdn for mISDN 1.2 or later.])])
- AC_CHECK_MEMBER([Q931_info_t.redirect_dn], [], [PBX_MISDN=0], [#include <mISDNuser/mISDNlib.h>])
- fi
-
-Index: apps/app_queue.c
-===================================================================
---- apps/app_queue.c (.../branches/1.8) (revision 336160)
-+++ apps/app_queue.c (.../team/irroot/distrotech-customers-1.8) (revision 336160)
-@@ -522,11 +522,25 @@
- <enum name="count">
- <para>Returns the total number of members for the specified queue.</para>
- </enum>
-+ <enum name="penalty">
-+ <para>Gets or sets queue member penalty.</para>
-+ </enum>
-+ <enum name="paused">
-+ <para>Gets or sets queue member paused status.</para>
-+ </enum>
-+ <enum name="ignorebusy">
-+ <para>Gets or sets queue member ignorebusy.</para>
-+ </enum>
- </enumlist>
- </parameter>
-+ <parameter name="interface" required="false" />
- </syntax>
- <description>
-- <para>Returns the number of members currently associated with the specified <replaceable>queuename</replaceable>.</para>
-+ <para>Allows access to queue counts [R] and member information [R/W].</para>
-+ <para>
-+ <replaceable>queuename</replaceable> is required for all operations
-+ <replaceable>interface</replaceable> is required for all member operations.
-+ </para>
- </description>
- <see-also>
- <ref type="application">Queue</ref>
-@@ -659,6 +673,7 @@
- </syntax>
- <description>
- <para>Gets or sets queue members penalty.</para>
-+ <warning><para>This function has been deprecated in favor of the <literal>QUEUE_MEMBER()</literal> function</para></warning>
- </description>
- <see-also>
- <ref type="application">Queue</ref>
-@@ -934,6 +949,12 @@
- /*! \brief queues.conf [general] option */
- static int update_cdr = 0;
-
-+/*! \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,
-@@ -1043,6 +1064,7 @@
- unsigned int dead:1; /*!< Used to detect members deleted in realtime */
- unsigned int delme:1; /*!< Flag to delete entry on reload */
- char rt_uniqueid[80]; /*!< Unique id of realtime member entry */
-+ unsigned int ignorebusy:1; /*!< Flag to ignore member if the status is not available */
- };
-
- enum empty_conditions {
-@@ -1160,6 +1182,7 @@
- int timeout; /*!< How long to wait for an answer */
- int weight; /*!< Respective weight */
- int autopause; /*!< Auto pause queue members if they fail to answer */
-+ int autopausedelay; /*!< Delay auto pause for autopausedelay seconds since last call */
- int timeoutpriority; /*!< Do we allow a fraction of the timeout to occur for a ring? */
-
- /* Queue strategy things */
-@@ -1190,9 +1213,12 @@
- static struct ao2_container *queues;
-
- static void update_realtime_members(struct call_queue *q);
-+static struct member *interface_exists(struct call_queue *q, const char *interface);
- 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 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)
- {
-@@ -1436,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
- );
-
-@@ -1552,7 +1579,7 @@
- return state;
- }
-
--static int extension_state_cb(char *context, char *exten, enum ast_extension_states state, void *data)
-+static int extension_state_cb(const char *context, const char *exten, enum ast_extension_states state, void *data)
- {
- struct ao2_iterator miter, qiter;
- struct member *m;
-@@ -1698,6 +1725,7 @@
- q->numperiodicannounce = 0;
- q->autopause = QUEUE_AUTOPAUSE_OFF;
- q->timeoutpriority = TIMEOUT_PRIORITY_APP;
-+ q->autopausedelay = 0;
- if (!q->members) {
- if (q->strategy == QUEUE_STRATEGY_LINEAR || q->strategy == QUEUE_STRATEGY_RRORDERED)
- /* linear strategy depends on order, so we have to place all members in a single bucket */
-@@ -2008,6 +2036,8 @@
- q->montype = 1;
- } else if (!strcasecmp(param, "autopause")) {
- q->autopause = autopause2int(val);
-+ } else if (!strcasecmp(param, "autopausedelay")) {
-+ q->autopausedelay = atoi(val);
- } else if (!strcasecmp(param, "maxlen")) {
- q->maxlen = atoi(val);
- if (q->maxlen < 0)
-@@ -2077,16 +2107,24 @@
- * \brief Find rt member record to update otherwise create one.
- *
- * Search for member in queue, if found update penalty/paused state,
-- * if no member exists create one flag it as a RT member and add to queue member list.
-+ * if no member exists create one flag it as a RT member and add to queue member list.
- */
--static void rt_handle_member_record(struct call_queue *q, char *interface, const char *rt_uniqueid, const char *membername, const char *penalty_str, const char *paused_str, const char* state_interface)
-+static void rt_handle_member_record(struct call_queue *q, char *interface, struct ast_config *member_config)
- {
- struct member *m;
- struct ao2_iterator mem_iter;
- int penalty = 0;
- int paused = 0;
- int found = 0;
-+ int ignorebusy = 0;
-
-+ const char *config_val;
-+ const char *rt_uniqueid = ast_variable_retrieve(member_config, interface, "uniqueid");
-+ const char *membername = S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface);
-+ const char *state_interface = S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface);
-+ const char *penalty_str = ast_variable_retrieve(member_config, interface, "penalty");
-+ const char *paused_str = ast_variable_retrieve(member_config, interface, "paused");
-+
- if (ast_strlen_zero(rt_uniqueid)) {
- ast_log(LOG_WARNING, "Realtime field uniqueid is empty for member %s\n", S_OR(membername, "NULL"));
- return;
-@@ -2094,8 +2132,11 @@
-
- if (penalty_str) {
- penalty = atoi(penalty_str);
-- if (penalty < 0)
-+ if ((penalty < 0) && negative_penalty_invalid) {
-+ return;
-+ } else if (penalty < 0) {
- penalty = 0;
-+ }
- }
-
- if (paused_str) {
-@@ -2104,33 +2145,45 @@
- paused = 0;
- }
-
-- /* Find member by realtime uniqueid and update */
-- mem_iter = ao2_iterator_init(q->members, 0);
-- while ((m = ao2_iterator_next(&mem_iter))) {
-- if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) {
-- m->dead = 0; /* Do not delete this one. */
-- ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));
-- if (paused_str)
-- m->paused = paused;
-- if (strcasecmp(state_interface, m->state_interface)) {
-- ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface));
-- }
-- m->penalty = penalty;
-- found = 1;
-- ao2_ref(m, -1);
-- break;
-- }
-- ao2_ref(m, -1);
-- }
-+ if ((config_val = ast_variable_retrieve(member_config, interface, "ignorebusy"))) {
-+ ignorebusy = ast_true(config_val);
-+ } else {
-+ ignorebusy = 1;
-+ }
-+
-+ /* Find member by realtime uniqueid and update */
-+ mem_iter = ao2_iterator_init(q->members, 0);
-+ while ((m = ao2_iterator_next(&mem_iter))) {
-+ if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) {
-+ m->dead = 0; /* Do not delete this one. */
-+ ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));
-+ if (paused_str)
-+ m->paused = paused;
-+ if (strcasecmp(state_interface, m->state_interface)) {
-+ ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface));
-+ }
-+ m->penalty = penalty;
-+ m->ignorebusy = ignorebusy;
-+ found = 1;
-+ ao2_ref(m, -1);
-+ break;
-+ }
-+ ao2_ref(m, -1);
-+ }
- ao2_iterator_destroy(&mem_iter);
-
-- /* Create a new member */
-- if (!found) {
-+ /* Create a new member */
-+ if (!found) {
- if ((m = create_queue_member(interface, membername, penalty, paused, state_interface))) {
- m->dead = 0;
- 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;
-@@ -2304,19 +2357,18 @@
- ao2_iterator_destroy(&mem_iter);
-
- while ((interface = ast_category_browse(member_config, interface))) {
-- rt_handle_member_record(q, interface,
-- ast_variable_retrieve(member_config, interface, "uniqueid"),
-- S_OR(ast_variable_retrieve(member_config, interface, "membername"),interface),
-- ast_variable_retrieve(member_config, interface, "penalty"),
-- ast_variable_retrieve(member_config, interface, "paused"),
-- S_OR(ast_variable_retrieve(member_config, interface, "state_interface"),interface));
-+ rt_handle_member_record(q, interface, member_config);
- }
-
- /* Delete all realtime members that have been deleted in DB. */
- 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--;
- }
-@@ -2425,19 +2477,18 @@
- ao2_iterator_destroy(&mem_iter);
-
- while ((interface = ast_category_browse(member_config, interface))) {
-- rt_handle_member_record(q, interface,
-- ast_variable_retrieve(member_config, interface, "uniqueid"),
-- S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface),
-- ast_variable_retrieve(member_config, interface, "penalty"),
-- ast_variable_retrieve(member_config, interface, "paused"),
-- S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface));
-+ rt_handle_member_record(q, interface, member_config);
- }
-
- /* Delete all realtime members that have been deleted in DB. */
- 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--;
- }
-@@ -2874,16 +2925,24 @@
- mem_iter = ao2_iterator_init(q->members, 0);
- while ((mem = ao2_iterator_next(&mem_iter))) {
- switch (mem->status) {
-- case AST_DEVICE_INUSE:
-- if (!q->ringinuse)
-+ case AST_DEVICE_INVALID:
-+ case AST_DEVICE_UNAVAILABLE:
- break;
-- /* else fall through */
-- case AST_DEVICE_NOT_INUSE:
-- case AST_DEVICE_UNKNOWN:
-- if (!mem->paused) {
-- avl++;
-- }
-- break;
-+ case AST_DEVICE_INUSE:
-+ case AST_DEVICE_BUSY:
-+ case AST_DEVICE_RINGING:
-+ case AST_DEVICE_RINGINUSE:
-+ case AST_DEVICE_ONHOLD:
-+ if ((!q->ringinuse) || (!mem->ignorebusy)) {
-+ break;
-+ }
-+ /* else fall through */
-+ case AST_DEVICE_NOT_INUSE:
-+ case AST_DEVICE_UNKNOWN:
-+ if (!mem->paused) {
-+ avl++;
-+ }
-+ break;
- }
- ao2_ref(mem, -1);
-
-@@ -3009,38 +3068,54 @@
- char tech[256];
- char *location;
- const char *macrocontext, *macroexten;
-+ enum ast_device_state newstate;
-
- /* on entry here, we know that tmp->chan == NULL */
-+ if (tmp->member->paused) {
-+ ast_debug(1, "%s paused, can't receive call\n", tmp->interface);
-+ if (qe->chan->cdr) {
-+ ast_cdr_busy(qe->chan->cdr);
-+ }
-+ tmp->stillgoing = 0;
-+ return 0;
-+ }
-+
- if ((tmp->lastqueue && tmp->lastqueue->wrapuptime && (time(NULL) - tmp->lastcall < tmp->lastqueue->wrapuptime)) ||
- (!tmp->lastqueue && qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime))) {
-- ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n",
-+ ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n",
- (tmp->lastqueue ? tmp->lastqueue->name : qe->parent->name), tmp->interface);
-- if (qe->chan->cdr)
-+ if (qe->chan->cdr) {
- ast_cdr_busy(qe->chan->cdr);
-+ }
- tmp->stillgoing = 0;
- (*busies)++;
- return 0;
- }
-
-- if (!qe->parent->ringinuse && (tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
-- ast_debug(1, "%s in use, can't receive call\n", tmp->interface);
-- if (qe->chan->cdr)
-- ast_cdr_busy(qe->chan->cdr);
-- tmp->stillgoing = 0;
-- return 0;
-+ if (!qe->parent->ringinuse || !tmp->member->ignorebusy) {
-+ if ((tmp->member->status == AST_DEVICE_UNKNOWN) || (tmp->member->status == AST_DEVICE_NOT_INUSE)) {
-+ newstate = ast_parse_device_state(tmp->member->interface);
-+ if (newstate != tmp->member->status) {
-+ ast_log(LOG_ERROR, "Found a channel matching iterface %s while status was %i changed to %i\n",
-+ tmp->member->interface, tmp->member->status, newstate);
-+ update_status(qe->parent, tmp->member, newstate);
-+ }
-+ }
-+ if ((tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
-+ ast_debug(1, "%s in use, can't receive call\n", tmp->interface);
-+ if (qe->chan->cdr) {
-+ ast_cdr_busy(qe->chan->cdr);
-+ }
-+ tmp->stillgoing = 0;
-+ return 0;
-+ }
- }
-
-- if (tmp->member->paused) {
-- ast_debug(1, "%s paused, can't receive call\n", tmp->interface);
-- if (qe->chan->cdr)
-- ast_cdr_busy(qe->chan->cdr);
-- tmp->stillgoing = 0;
-- return 0;
-- }
- if (use_weight && compare_weight(qe->parent,tmp->member)) {
- ast_debug(1, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
-- if (qe->chan->cdr)
-+ if (qe->chan->cdr) {
- ast_cdr_busy(qe->chan->cdr);
-+ }
- tmp->stillgoing = 0;
- (*busies)++;
- return 0;
-@@ -3055,8 +3130,9 @@
- /* Request the peer */
- tmp->chan = ast_request(tech, qe->chan->nativeformats, qe->chan, location, &status);
- 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);
-+ }
- tmp->stillgoing = 0;
-
- ao2_lock(qe->parent);
-@@ -3395,6 +3471,18 @@
- }
- ast_queue_log(qe->parent->name, qe->chan->uniqueid, membername, "RINGNOANSWER", "%d", rnatime);
- if (qe->parent->autopause != QUEUE_AUTOPAUSE_OFF && pause) {
-+ if (qe->parent->autopausedelay > 0) {
-+ struct member *mem;
-+ ao2_lock(qe->parent);
-+ if ((mem = interface_exists(qe->parent, interface))) {
-+ time_t idletime = time(&idletime)-mem->lastcall;
-+ if ((mem->lastcall != 0) && (qe->parent->autopausedelay > idletime)) {
-+ ao2_unlock(qe->parent);
-+ return;
-+ }
-+ }
-+ ao2_unlock(qe->parent);
-+ }
- if (qe->parent->autopause == QUEUE_AUTOPAUSE_ON) {
- if (!set_member_paused(qe->parent->name, interface, "Auto-Pause", 1)) {
- ast_verb(3, "Auto-Pausing Queue Member %s in queue %s since they failed to answer.\n",
-@@ -4692,8 +4780,9 @@
- else
- ast_moh_stop(qe->chan);
- /* If appropriate, log that we have a destination channel */
-- if (qe->chan->cdr)
-+ if (qe->chan->cdr) {
- ast_cdr_setdestchan(qe->chan->cdr, peer->name);
-+ }
- /* Make sure channels are compatible */
- res = ast_channel_make_compatible(qe->chan, peer);
- if (res < 0) {
-@@ -4773,10 +4862,11 @@
- if (mixmonapp) {
- ast_debug(1, "Starting MixMonitor as requested.\n");
- if (!monitorfilename) {
-- if (qe->chan->cdr)
-+ if (qe->chan->cdr) {
- ast_copy_string(tmpid, qe->chan->cdr->uniqueid, sizeof(tmpid));
-- else
-+ } else {
- snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random());
-+ }
- } else {
- const char *m = monitorfilename;
- for (p = tmpid2; p < tmpid2 + sizeof(tmpid2) - 1; p++, m++) {
-@@ -4843,12 +4933,13 @@
-
- ast_debug(1, "Arguments being passed to MixMonitor: %s\n", mixmonargs);
- /* We purposely lock the CDR so that pbx_exec does not update the application data */
-- if (qe->chan->cdr)
-+ if (qe->chan->cdr) {
- ast_set_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED);
-+ }
- pbx_exec(qe->chan, mixmonapp, mixmonargs);
-- if (qe->chan->cdr)
-+ if (qe->chan->cdr) {
- ast_clear_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED);
--
-+ }
- } else {
- ast_log(LOG_WARNING, "Asked to run MixMonitor on this call, but cannot find the MixMonitor app!\n");
- }
-@@ -4984,8 +5075,26 @@
- qe->handled++;
- ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "CONNECT", "%ld|%s|%ld", (long) time(NULL) - qe->start, peer->uniqueid,
- (long)(orig - to > 0 ? (orig - to) / 1000 : 0));
-- if (update_cdr && qe->chan->cdr)
-- ast_copy_string(qe->chan->cdr->dstchannel, member->membername, sizeof(qe->chan->cdr->dstchannel));
-+
-+ if (update_cdr && qe->chan->cdr) {
-+ struct ast_cdr *cdr;
-+ struct ast_cdr *newcdr;
-+
-+ cdr = qe->chan->cdr;
-+ while (cdr->next) {
-+ cdr = cdr->next;
-+ }
-+ if ((strcasecmp(cdr->uniqueid, qe->chan->uniqueid)) && (strcasecmp(cdr->linkedid, qe->chan->uniqueid))) {
-+ if ((newcdr = ast_cdr_dup(cdr))) {
-+ ast_cdr_init(newcdr, qe->chan);
-+ ast_cdr_reset(newcdr, 0);
-+ cdr->next = newcdr;
-+ cdr = cdr->next;
-+ }
-+ }
-+ ast_copy_string(cdr->dstchannel, member->membername, sizeof(cdr->dstchannel));
-+ }
-+
- if (qe->parent->eventwhencalled)
- manager_event(EVENT_FLAG_AGENT, "AgentConnect",
- "Queue: %s\r\n"
-@@ -5166,7 +5275,10 @@
- ao2_lock(q);
- if ((mem = ao2_find(q->members, &tmpmem, OBJ_POINTER))) {
- /* XXX future changes should beware of this assumption!! */
-- if (!mem->dynamic) {
-+ /*Change Penalty on realtime users*/
-+ if (mem->realtime && !ast_strlen_zero(mem->rt_uniqueid) && negative_penalty_invalid) {
-+ update_realtime_member_field(mem, q->name, "penalty", "-1");
-+ } else if (!mem->dynamic) {
- ao2_ref(mem, -1);
- ao2_unlock(q);
- queue_t_unref(q, "Interface wasn't dynamic, expiring temporary reference");
-@@ -5223,13 +5335,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);
-@@ -5336,35 +5449,34 @@
- int foundinterface = 0, foundqueue = 0;
- struct call_queue *q;
- struct member *mem;
-- struct ao2_iterator queue_iter;
-+ char rtpenalty[80];
-
-- if (penalty < 0) {
-+ if (penalty < 0 && !negative_penalty_invalid) {
- ast_log(LOG_ERROR, "Invalid penalty (%d)\n", penalty);
- return RESULT_FAILURE;
- }
-
-- queue_iter = ao2_iterator_init(queues, 0);
-- while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
-+ if ((q = load_realtime_queue(queuename))) {
-+ foundqueue++;
- ao2_lock(q);
-- if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename)) {
-- foundqueue++;
-- if ((mem = interface_exists(q, interface))) {
-- foundinterface++;
-+ if ((mem = interface_exists(q, interface))) {
-+ foundinterface++;
-+ if (!mem->realtime) {
- mem->penalty = penalty;
--
-- ast_queue_log(q->name, "NONE", interface, "PENALTY", "%d", penalty);
-- manager_event(EVENT_FLAG_AGENT, "QueueMemberPenalty",
-- "Queue: %s\r\n"
-- "Location: %s\r\n"
-- "Penalty: %d\r\n",
-- q->name, mem->interface, penalty);
-- ao2_ref(mem, -1);
-+ } else {
-+ sprintf(rtpenalty,"%i", penalty);
-+ update_realtime_member_field(mem, q->name, "penalty", rtpenalty);
- }
-+ ast_queue_log(q->name, "NONE", interface, "PENALTY", "%d", penalty);
-+ manager_event(EVENT_FLAG_AGENT, "QueueMemberPenalty",
-+ "Queue: %s\r\n"
-+ "Location: %s\r\n"
-+ "Penalty: %d\r\n",
-+ q->name, mem->interface, penalty);
-+ ao2_ref(mem, -1);
- }
- ao2_unlock(q);
-- queue_t_unref(q, "Done with iterator");
- }
-- ao2_iterator_destroy(&queue_iter);
-
- if (foundinterface) {
[... 4839 lines stripped ...]
More information about the asterisk-commits
mailing list