[asterisk-commits] mmichelson: trunk r261051 - in /trunk: ./ apps/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 4 17:46:47 CDT 2010


Author: mmichelson
Date: Tue May  4 17:46:42 2010
New Revision: 261051

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=261051
Log:
Add new possible value to autopause option to allow members to be autopaused in all queues.

See the CHANGES file and queues.conf.sample for more details.

(closes issue #17008)
Reported by: jlpedrosa
Patches:
      queues.autopause_en_review.diff uploaded by jlpedrosa (license 1002)

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


Modified:
    trunk/CHANGES
    trunk/apps/app_queue.c
    trunk/configs/queues.conf.sample

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=261051&r1=261050&r2=261051
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Tue May  4 17:46:42 2010
@@ -235,6 +235,10 @@
   * A 'relative-peroidic-announce' option has been added to queues.conf.  When
     enabled, this option will cause periodic announce times to be calculated
     from the end of announcements rather than from the beginning.
+  * The autopause option in queues.conf can be passed a new value, "all." The
+    result is that if a member becomes auto-paused, he will be paused in all
+	queues for which he is a member, not just the queue that failed to reach
+	the member.
 
 mISDN channel driver (chan_misdn) changes
 ----------------------------------------

Modified: trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_queue.c?view=diff&rev=261051&r1=261050&r2=261051
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Tue May  4 17:46:42 2010
@@ -671,6 +671,12 @@
 	QUEUE_STRATEGY_WRANDOM
 };
 
+enum {
+     QUEUE_AUTOPAUSE_OFF = 0,
+     QUEUE_AUTOPAUSE_ON,
+     QUEUE_AUTOPAUSE_ALL
+};
+
 enum queue_reload_mask {
 	QUEUE_RELOAD_PARAMETERS = (1 << 0),
 	QUEUE_RELOAD_MEMBER = (1 << 1),
@@ -691,6 +697,16 @@
 	{ QUEUE_STRATEGY_LINEAR, "linear" },
 	{ QUEUE_STRATEGY_WRANDOM, "wrandom"},
 };
+
+static const struct autopause {
+	int autopause;
+	const char *name;
+} autopausesmodes [] = {
+	{ QUEUE_AUTOPAUSE_OFF,"no" },
+	{ QUEUE_AUTOPAUSE_ON, "yes" },
+	{ QUEUE_AUTOPAUSE_ALL,"all" },
+};
+
 
 static struct ast_taskprocessor *devicestate_tps;
 
@@ -1037,6 +1053,26 @@
 	return -1;
 }
 
+static int autopause2int(const char *autopause)
+{
+	int x;
+	/*This 'double check' that default value is OFF */
+	if (ast_strlen_zero(autopause))
+		return QUEUE_AUTOPAUSE_OFF;
+
+	/*This 'double check' is to ensure old values works */
+	if(ast_true(autopause))
+		return QUEUE_AUTOPAUSE_ON;
+
+	for (x = 0; x < ARRAY_LEN(autopausesmodes); x++) {
+		if (!strcasecmp(autopause, autopausesmodes[x].name))
+			return autopausesmodes[x].autopause;
+	}
+
+	/*This 'double check' that default value is OFF */
+	return QUEUE_AUTOPAUSE_OFF;
+}
+
 static int queue_hash_cb(const void *obj, const int flags)
 {
 	const struct call_queue *q = obj;
@@ -1466,6 +1502,7 @@
 	q->periodicannouncefrequency = 0;
 	q->randomperiodicannounce = 0;
 	q->numperiodicannounce = 0;
+	q->autopause = QUEUE_AUTOPAUSE_OFF;
 	q->timeoutpriority = TIMEOUT_PRIORITY_APP;
 	if (!q->members) {
 		if (q->strategy == QUEUE_STRATEGY_LINEAR)
@@ -1771,7 +1808,7 @@
 		if (!strcasecmp(val, "mixmonitor"))
 			q->montype = 1;
 	} else if (!strcasecmp(param, "autopause")) {
-		q->autopause = ast_true(val);
+		q->autopause = autopause2int(val);
 	} else if (!strcasecmp(param, "maxlen")) {
 		q->maxlen = atoi(val);
 		if (q->maxlen < 0)
@@ -3128,11 +3165,23 @@
 						qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
 	}
 	ast_queue_log(qe->parent->name, qe->chan->uniqueid, membername, "RINGNOANSWER", "%d", rnatime);
-	if (qe->parent->autopause && pause) {
-		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", interface, qe->parent->name);
+	if (qe->parent->autopause != QUEUE_AUTOPAUSE_OFF && pause) {
+		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",
+					interface, qe->parent->name);
+			} else {
+				ast_verb(3, "Failed to pause Queue Member %s in queue %s!\n", interface, qe->parent->name);
+			}
 		} else {
-			ast_verb(3, "Failed to pause Queue Member %s in queue %s!\n", interface, qe->parent->name);
+			/* If queue autopause is mode all, just don't send any queue to stop.
+			* the function will stop in all queues */
+			if (!set_member_paused("", interface, "Auto-Pause", 1)) {
+				ast_verb(3, "Auto-Pausing Queue Member %s in all queues since they failed to answer on queue %s.\n",
+						interface, qe->parent->name);
+			} else {
+					ast_verb(3, "Failed to pause Queue Member %s in all queues!\n", interface);
+			}
 		}
 	}
 	return;

Modified: trunk/configs/queues.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/queues.conf.sample?view=diff&rev=261051&r1=261050&r2=261051
==============================================================================
--- trunk/configs/queues.conf.sample (original)
+++ trunk/configs/queues.conf.sample Tue May  4 17:46:42 2010
@@ -190,7 +190,9 @@
 ;autofill=yes
 ;
 ; Autopause will pause a queue member if they fail to answer a call
-;
+; no: Member will not be paused
+; yes: Member will be paused only in the queue where the timeout took place
+; all: Memeber will be paused in all queues he/she is a member
 ;autopause=yes
 ;
 ; Maximum number of people waiting in the queue (0 for unlimited)




More information about the asterisk-commits mailing list