[asterisk-commits] trunk r25889 - /trunk/apps/app_queue.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 9 00:27:04 MST 2006


Author: russell
Date: Tue May  9 02:27:03 2006
New Revision: 25889

URL: http://svn.digium.com/view/asterisk?rev=25889&view=rev
Log:
put all the QUEUE_STRATEGY values in an enum, and use them in all of the places
in the code where the strategy type is checked, to make the code more readable

Modified:
    trunk/apps/app_queue.c

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=25889&r1=25888&r2=25889&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Tue May  9 02:27:03 2006
@@ -93,12 +93,14 @@
 #include "asterisk/devicestate.h"
 #include "asterisk/stringfields.h"
 
-#define QUEUE_STRATEGY_RINGALL		0
-#define QUEUE_STRATEGY_ROUNDROBIN	1
-#define QUEUE_STRATEGY_LEASTRECENT	2
-#define QUEUE_STRATEGY_FEWESTCALLS	3
-#define QUEUE_STRATEGY_RANDOM		4
-#define QUEUE_STRATEGY_RRMEMORY		5
+enum {
+	QUEUE_STRATEGY_RINGALL = 0,
+	QUEUE_STRATEGY_ROUNDROBIN,
+	QUEUE_STRATEGY_LEASTRECENT,
+	QUEUE_STRATEGY_FEWESTCALLS,
+	QUEUE_STRATEGY_RANDOM,
+	QUEUE_STRATEGY_RRMEMORY
+};
 
 static struct strategy {
 	int strategy;
@@ -732,7 +734,7 @@
 		if (q->strategy < 0) {
 			ast_log(LOG_WARNING, "'%s' isn't a valid strategy for queue '%s', using ringall instead\n",
 				val, q->name);
-			q->strategy = 0;
+			q->strategy = QUEUE_STRATEGY_RINGALL;
 		}
 	} else if (!strcasecmp(param, "joinempty")) {
 		if (!strcasecmp(val, "strict"))
@@ -1526,7 +1528,7 @@
 				ast_log(LOG_DEBUG, "Nobody left to try ringing in queue\n");
 			break;
 		}
-		if (!qe->parent->strategy) {
+		if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
 			struct callattempt *cur;
 			/* Ring everyone who shares this best metric (for ringall) */
 			for (cur = outgoing; cur; cur = cur->q_next) {
@@ -1686,7 +1688,7 @@
 				numlines++;
 			}
 			if (pos > 1 /* found */ || !stillgoing /* nobody listening */ ||
-					 qe->parent->strategy /* ring would not be delivered */)
+					 (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) /* ring would not be delivered */)
 				break;
 			/* On "ringall" strategy we only move to the next penalty level
 			   when *all* ringing phones are done in the current penalty level */
@@ -1784,7 +1786,7 @@
 							if (in->cdr)
 								ast_cdr_busy(in->cdr);
 							do_hang(o);
-							if (qe->parent->strategy) {
+							if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
 								if (qe->parent->timeoutrestart)
 									*to = orig;
 								ring_one(qe, outgoing, &numbusies);
@@ -1797,7 +1799,7 @@
 							if (in->cdr)
 								ast_cdr_busy(in->cdr);
 							do_hang(o);
-							if (qe->parent->strategy) {
+							if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
 								if (qe->parent->timeoutrestart)
 									*to = orig;
 								ring_one(qe, outgoing, &numbusies);
@@ -1824,7 +1826,7 @@
 					ast_frfree(f);
 				} else {
 					do_hang(o);
-					if (qe->parent->strategy) {
+					if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) {
 						if (qe->parent->timeoutrestart)
 							*to = orig;
 						ring_one(qe, outgoing, &numbusies);
@@ -1925,7 +1927,7 @@
 		if (option_debug)
 			ast_log(LOG_DEBUG, "There are %d available members.\n", avl);
 	
-		if (qe->parent->strategy == 0) {
+		if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) {
 			if (option_debug)
 				ast_log(LOG_DEBUG, "Even though there are %d available members, the strategy is ringall so only the head call is allowed in!\n", avl);
 			avl = 1;



More information about the asterisk-commits mailing list