Adding the queue strategy wrandom

(closes issue #10942, reported and patched by julianjm, documentation changes by me)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89070 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2007-11-06 22:36:55 +00:00
parent a06218ee6d
commit 0cd3118a62
3 changed files with 14 additions and 1 deletions

View File

@@ -101,7 +101,8 @@ enum {
QUEUE_STRATEGY_FEWESTCALLS,
QUEUE_STRATEGY_RANDOM,
QUEUE_STRATEGY_RRMEMORY,
QUEUE_STRATEGY_LINEAR
QUEUE_STRATEGY_LINEAR,
QUEUE_STRATEGY_WRANDOM
};
static struct strategy {
@@ -114,6 +115,7 @@ static struct strategy {
{ QUEUE_STRATEGY_RANDOM, "random" },
{ QUEUE_STRATEGY_RRMEMORY, "rrmemory" },
{ QUEUE_STRATEGY_LINEAR, "linear" },
{ QUEUE_STRATEGY_WRANDOM, "wrandom"},
};
#define DEFAULT_RETRY 5
@@ -2597,6 +2599,9 @@ static int calc_metric(struct call_queue *q, struct member *mem, int pos, struct
tmp->metric = ast_random() % 1000;
tmp->metric += mem->penalty * 1000000;
break;
case QUEUE_STRATEGY_WRANDOM:
tmp->metric = ast_random() % ((1 + mem->penalty) * 1000);
break;
case QUEUE_STRATEGY_FEWESTCALLS:
tmp->metric = mem->calls;
tmp->metric += mem->penalty * 1000000;