[svn-commits] irroot: branch irroot/asterisk-trunk-quack-queue r345367 - /team/irroot/aster...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Nov 15 09:04:18 CST 2011
Author: irroot
Date: Tue Nov 15 09:04:15 2011
New Revision: 345367
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=345367
Log:
Add back QUEUE_WAITING_COUNT fixup watching and null ref
Modified:
team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c
Modified: team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c?view=diff&rev=345367&r1=345366&r2=345367
==============================================================================
--- team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c (original)
+++ team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c Tue Nov 15 09:04:15 2011
@@ -269,6 +269,7 @@
<ref type="function">QUEUE_VARIABLES</ref>
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -309,6 +310,7 @@
<ref type="function">QUEUE_VARIABLES</ref>
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -344,6 +346,7 @@
<ref type="function">QUEUE_VARIABLES</ref>
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -386,6 +389,7 @@
<ref type="function">QUEUE_VARIABLES</ref>
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -425,6 +429,7 @@
<ref type="function">QUEUE_VARIABLES</ref>
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -454,6 +459,7 @@
<ref type="function">QUEUE_VARIABLES</ref>
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -506,6 +512,7 @@
<ref type="function">QUEUE_VARIABLES</ref>
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -560,6 +567,7 @@
<ref type="function">QUEUE_VARIABLES</ref>
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -585,6 +593,33 @@
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_MEMBER_COUNT</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
+ <ref type="function">QUEUE_MEMBER_LIST</ref>
+ <ref type="function">QUEUE_MEMBER_PENALTY</ref>
+ </see-also>
+ </function>
+ <function name="QUEUE_WAITING_COUNT" language="en_US">
+ <synopsis>
+ Count number of calls currently waiting in a queue.
+ </synopsis>
+ <syntax>
+ <parameter name="queuename" />
+ </syntax>
+ <description>
+ <para>Returns the number of callers currently waiting in the specified <replaceable>queuename</replaceable>.</para>
+ </description>
+ <see-also>
+ <ref type="application">Queue</ref>
+ <ref type="application">QueueLog</ref>
+ <ref type="application">AddQueueMember</ref>
+ <ref type="application">RemoveQueueMember</ref>
+ <ref type="application">PauseQueueMember</ref>
+ <ref type="application">UnpauseQueueMember</ref>
+ <ref type="function">QUEUE_VARIABLES</ref>
+ <ref type="function">QUEUE_MEMBER</ref>
+ <ref type="function">QUEUE_MEMBER_COUNT</ref>
+ <ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -610,6 +645,7 @@
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_MEMBER_COUNT</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -637,6 +673,7 @@
<ref type="function">QUEUE_MEMBER</ref>
<ref type="function">QUEUE_MEMBER_COUNT</ref>
<ref type="function">QUEUE_EXISTS</ref>
+ <ref type="function">QUEUE_WAITING_COUNT</ref>
<ref type="function">QUEUE_MEMBER_LIST</ref>
<ref type="function">QUEUE_MEMBER_PENALTY</ref>
</see-also>
@@ -1699,7 +1736,7 @@
{
const struct member *mem1 = obj1;
const struct member *mem2 = obj2;
- const char *arg = (flags & OBJ_POINTER) ? mem2->interface : obj2;
+ const char *arg = (obj2 && flags & OBJ_POINTER) ? mem2->interface : obj2;
return strcasecmp(mem1->interface, arg) ? 0 : CMP_MATCH | CMP_STOP;
}
@@ -1867,8 +1904,8 @@
{
const struct callattempt *c = obj;
const struct callattempt *c1 = arg;
- const struct member *mem = c1->member;
- const char *interface = (flags & OBJ_KEY) ? obj : mem->interface;
+ const struct member *mem = (arg) ? c1->member : NULL;
+ const char *interface = (arg && flags & OBJ_POINTER) ? mem->interface : arg;
if (!arg || ast_strlen_zero(interface) || !strcasecmp(interface, c->member->interface)) {
return (c->watching) ? CMP_MATCH : 0;
@@ -2444,9 +2481,9 @@
/* i have just been born */
if (!log_membername_as_agent) {
- ast_queue_log(q->name, source, m->interface, "ADDMEMBER", "%s", "");
+ ast_queue_log(q->name, source, m->interface, "ADDMEMBER", "%s", m->paused ? "PAUSED" : "");
} else {
- ast_queue_log(q->name, source, m->membername, "ADDMEMBER", "%s", "");
+ ast_queue_log(q->name, source, m->membername, "ADDMEMBER", "%s", m->paused ? "PAUSED" : "");
}
manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded",
"Queue: %s\r\n"
@@ -3895,6 +3932,9 @@
/* Service all of the outgoing channels */
calls = ao2_find(qe->attempts, NULL, OBJ_MULTIPLE);
while (calls && (o = ao2_iterator_next(calls))) {
+ /* i need to be re added to the watchers */
+ o->watching = 0;
+
/* We go with a static buffer here instead of using ast_strdupa. Using
* ast_strdupa in a loop like this one can cause a stack overflow
*/
@@ -3904,7 +3944,7 @@
ast_copy_string(ochan_name, o->chan->name, sizeof(ochan_name));
ast_channel_unlock(o->chan);
}
- if (o->stillgoing && (o->chan) && (o->chan->_state == AST_STATE_UP)) {
+ if (o->stillgoing && o->chan && (o->chan->_state == AST_STATE_UP)) {
if (!peer) {
ast_verb(3, "%s answered %s\n", ochan_name, inchan_name);
if (update_connectedline) {
@@ -6752,6 +6792,40 @@
return ret;
}
+/*! \brief Dialplan function QUEUE_WAITING_COUNT() Get number callers waiting in a specific queue */
+static int queue_function_queuewaitingcount(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ int count = 0;
+ struct call_queue *q;
+ struct ast_variable *var = NULL;
+
+ buf[0] = '\0';
+
+ if (ast_strlen_zero(data)) {
+ ast_log(LOG_ERROR, "QUEUE_WAITING_COUNT requires an argument: queuename\n");
+ return -1;
+ }
+
+ if ((q = ao2_t_find(queues, data, OBJ_KEY, "Find for QUEUE_WAITING_COUNT()"))) {
+ ao2_lock(q->data);
+ count = q->data->count;
+ ao2_unlock(q->data);
+ ao2_t_ref(q, -1, "Done with reference in QUEUE_WAITING_COUNT()");
+ } else if ((var = ast_load_realtime("queues", "name", data, SENTINEL))) {
+ /* if the queue is realtime but was not found in memory, this
+ * means that the queue had been deleted from memory since it was
+ * "dead." This means it has a 0 waiting count
+ */
+ count = 0;
+ ast_variables_destroy(var);
+ } else
+ ast_log(LOG_WARNING, "queue %s was not found\n", data);
+
+ snprintf(buf, len, "%d", count);
+
+ return 0;
+}
+
/*! \brief Dialplan function QUEUE_MEMBER_LIST() Get list of members in a specific queue */
static int queue_function_queuememberlist(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
@@ -6896,6 +6970,11 @@
.name = "QUEUE_MEMBER",
.read = queue_function_mem_read,
.write = queue_function_mem_write,
+};
+
+static struct ast_custom_function queuewaitingcount_function = {
+ .name = "QUEUE_WAITING_COUNT",
+ .read = queue_function_queuewaitingcount,
};
static struct ast_custom_function queuememberlist_function = {
@@ -8966,6 +9045,7 @@
res |= ast_custom_function_unregister(&queuevar_function);
res |= ast_custom_function_unregister(&queuemembercount_function);
res |= ast_custom_function_unregister(&queuememberlist_function);
+ res |= ast_custom_function_unregister(&queuewaitingcount_function);
res |= ast_custom_function_unregister(&queuememberpenalty_function);
res |= ast_data_unregister(NULL);
@@ -9045,6 +9125,7 @@
res |= ast_custom_function_register(&queueexists_function);
res |= ast_custom_function_register(&queuemembercount_function);
res |= ast_custom_function_register(&queuememberlist_function);
+ res |= ast_custom_function_register(&queuewaitingcount_function);
res |= ast_custom_function_register(&queuememberpenalty_function);
if (!(devicestate_tps = ast_taskprocessor_get("app_queue", 0))) {
More information about the svn-commits
mailing list