Changing a bit of logic so that someone will NEVER exit the queue on timeout unless they have enabled the 'n' option.

This commit relates to issue #10320. Thanks to jfitzgibbon for detailing the idea behind this code change.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@78575 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Mark Michelson 18 years ago
parent c98e199fb2
commit f8c70a5799

@ -2342,7 +2342,7 @@ static int calc_metric(struct call_queue *q, struct member *mem, int pos, struct
return 0; return 0;
} }
static int try_calling(struct queue_ent *qe, const char *options, char *announceoverride, const char *url, int *go_on, const char *agi) static int try_calling(struct queue_ent *qe, const char *options, char *announceoverride, const char *url, int *tries, int *noption, const char *agi)
{ {
struct member *cur; struct member *cur;
struct callattempt *outgoing = NULL; /* the list of calls we are building */ struct callattempt *outgoing = NULL; /* the list of calls we are building */
@ -2377,7 +2377,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
char vars[2048]; char vars[2048];
int forwardsallowed = 1; int forwardsallowed = 1;
int callcompletedinsl; int callcompletedinsl;
int noption = 0;
memset(&bridge_config, 0, sizeof(bridge_config)); memset(&bridge_config, 0, sizeof(bridge_config));
time(&now); time(&now);
@ -2407,19 +2406,16 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
break; break;
case 'n': case 'n':
if (qe->parent->strategy == QUEUE_STRATEGY_ROUNDROBIN || qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY) if (qe->parent->strategy == QUEUE_STRATEGY_ROUNDROBIN || qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY)
(*go_on)++; (*tries)++;
else else
*go_on = qe->parent->membercount; *tries = qe->parent->membercount;
noption = 1; *noption = 1;
break; break;
case 'i': case 'i':
forwardsallowed = 0; forwardsallowed = 0;
break; break;
} }
if(!noption)
*go_on = -1;
/* Hold the lock while we setup the outgoing calls */ /* Hold the lock while we setup the outgoing calls */
if (use_weight) if (use_weight)
AST_LIST_LOCK(&queues); AST_LIST_LOCK(&queues);
@ -3367,7 +3363,8 @@ static int queue_exec(struct ast_channel *chan, void *data)
int max_penalty; int max_penalty;
enum queue_result reason = QUEUE_UNKNOWN; enum queue_result reason = QUEUE_UNKNOWN;
/* whether to exit Queue application after the timeout hits */ /* whether to exit Queue application after the timeout hits */
int go_on = 0; int tries = 0;
int noption = 0;
char *parse; char *parse;
AST_DECLARE_APP_ARGS(args, AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(queuename); AST_APP_ARG(queuename);
@ -3497,14 +3494,14 @@ check_turns:
goto stop; goto stop;
/* Try calling all queue members for 'timeout' seconds */ /* Try calling all queue members for 'timeout' seconds */
res = try_calling(&qe, args.options, args.announceoverride, args.url, &go_on, args.agi); res = try_calling(&qe, args.options, args.announceoverride, args.url, &tries, &noption, args.agi);
if (res) if (res)
goto stop; goto stop;
stat = get_member_status(qe.parent, qe.max_penalty); stat = get_member_status(qe.parent, qe.max_penalty);
/* exit after 'timeout' cycle if 'n' option enabled */ /* exit after 'timeout' cycle if 'n' option enabled */
if (go_on >= qe.parent->membercount) { if (noption && tries >= qe.parent->membercount) {
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Exiting on time-out cycle\n"); ast_verbose(VERBOSE_PREFIX_3 "Exiting on time-out cycle\n");
ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos); ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos);

Loading…
Cancel
Save