[asterisk-commits] alecdavis: trunk r373805 - in /trunk: ./ apps/app_queue.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 26 03:31:50 CDT 2012


Author: alecdavis
Date: Wed Sep 26 03:31:46 2012
New Revision: 373805

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373805
Log:
app_queue: 'agent available' hint, cleanup restart, and initial state

Fix previously untested senarios;

1). On queue initialisation set queue_avail devstate to INUSE.
    Previously was unavailable, which indicated an agent was available.

2). When removing members, if there are no other members available, set queue_avail to INUSE.
    Previously, if a member interface had become 'unavailable', they were never going to be removed, particularly when persistant queues is enabled.

3). When adding a member, check that they are available, if they are set queue_avail to NOT_INUSE.
 Previously on reloaded, members may have been 'unavailable'.

4). When pausing or unpausing a member, set appropriate queue availability. 

alecdavis (license 585)
Reported by: Alec Davis
Tested by: alecdavis

Review: https://reviewboard.asterisk.org/r/2129/
........

Merged revisions 373804 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/apps/app_queue.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_queue.c?view=diff&rev=373805&r1=373804&r2=373805
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Wed Sep 26 03:31:46 2012
@@ -2018,6 +2018,15 @@
 	while ((pr_iter = AST_LIST_REMOVE_HEAD(&q->rules,list))) {
 		ast_free(pr_iter);
 	}
+
+	/* On restart assume no members are available.
+	 * The queue_avail hint is a boolean state to indicate whether a member is available or not.
+	 *
+	 * This seems counter intuitive, but is required to light a BLF
+	 * AST_DEVICE_INUSE indicates no members are available.
+	 * AST_DEVICE_NOT_INUSE indicates a member is available.
+	 */
+	ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
 }
 
 static void clear_queue(struct call_queue *q)
@@ -5900,7 +5909,7 @@
 				dump_queue_members(q);
 			}
 
-			if (!ao2_container_count(q->members)) {
+			if (!num_available_members(q)) {
 				ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
 			}
 
@@ -5977,15 +5986,15 @@
 				new_member->penalty, new_member->calls, (int) new_member->lastcall,
 				new_member->status, new_member->paused);
 
+			if (is_member_available(new_member)) {
+				ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
+			}
+
 			ao2_ref(new_member, -1);
 			new_member = NULL;
 
 			if (dump) {
 				dump_queue_members(q);
-			}
-
-			if (ao2_container_count(q->members) == 1) {
-				ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
 			}
 
 			res = RES_OKAY;
@@ -6046,6 +6055,12 @@
 
 				if (queue_persistent_members) {
 					dump_queue_members(q);
+				}
+
+				if (is_member_available(mem)) {
+					ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
+				} else if (!num_available_members(q)) {
+					ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
 				}
 
 				ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"), "%s", S_OR(reason, ""));




More information about the asterisk-commits mailing list