[asterisk-commits] mmichelson: branch mmichelson/queue-penalty r93828 - /team/mmichelson/queue-p...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Dec 18 18:23:19 CST 2007
Author: mmichelson
Date: Tue Dec 18 18:23:19 2007
New Revision: 93828
URL: http://svn.digium.com/view/asterisk?view=rev&rev=93828
Log:
During a test I got the max_penalty to go negative on a relative change. This change
makes sure that the penalty bottoms out at 0.
Also a couple of coding guidelines-related cleanups
Modified:
team/mmichelson/queue-penalty/apps/app_queue.c
Modified: team/mmichelson/queue-penalty/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-penalty/apps/app_queue.c?view=diff&rev=93828&r1=93827&r2=93828
==============================================================================
--- team/mmichelson/queue-penalty/apps/app_queue.c (original)
+++ team/mmichelson/queue-penalty/apps/app_queue.c Tue Dec 18 18:23:19 2007
@@ -893,7 +893,7 @@
ast_str_set(&q->sound_periodicannounce[i], 0, "%s", "");
}
- while((pr_iter = AST_LIST_REMOVE_HEAD(&q->rules,list)))
+ while ((pr_iter = AST_LIST_REMOVE_HEAD(&q->rules,list)))
ast_free(pr_iter);
}
@@ -1806,7 +1806,7 @@
else
q->head = cur->next;
/* Free penalty rules */
- while((pr_iter = AST_LIST_REMOVE_HEAD(&qe->qe_rules, list)))
+ while ((pr_iter = AST_LIST_REMOVE_HEAD(&qe->qe_rules, list)))
ast_free(pr_iter);
} else {
/* Renumber the people after us in the queue based on a new count */
@@ -2634,6 +2634,9 @@
while (qe->pr && ((time(NULL) - qe->start) > qe->pr->time)) {
int max_penalty = qe->pr->relative ? qe->max_penalty + qe->pr->value : qe->pr->value;
char max_penalty_str[12]; /*XXX Will change this idiom and probably optimize things once everything is running */
+ /* a relative change to the penalty could put it below 0 */
+ if (max_penalty < 0)
+ max_penalty = 0;
snprintf(max_penalty_str, sizeof(max_penalty_str) - 1, "%d", max_penalty);
pbx_builtin_setvar_helper(qe->chan, "QUEUE_MAX_PENALTY", max_penalty_str);
qe->max_penalty = max_penalty;
@@ -4244,6 +4247,9 @@
while (qe.pr && ((time(NULL) - qe.start) > qe.pr->time)) {
char max_penalty_str[12]; /*XXX Will change this idiom and probably optimize things once everything is running */
max_penalty = qe.pr->relative ? qe.max_penalty + qe.pr->value : qe.pr->value;
+ /* A relative change could put the max_penalty below 0 */
+ if (max_penalty < 0)
+ max_penalty = 0;
snprintf(max_penalty_str, sizeof(max_penalty_str) - 1, "%d", max_penalty);
pbx_builtin_setvar_helper(qe.chan, "QUEUE_MAX_PENALTY", max_penalty_str);
qe.max_penalty = max_penalty;
More information about the asterisk-commits
mailing list