[svn-commits] mmichelson: branch mmichelson/queue-reset r101076 - /team/mmichelson/queue-re...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Jan 29 17:26:38 CST 2008
Author: mmichelson
Date: Tue Jan 29 17:26:37 2008
New Revision: 101076
URL: http://svn.digium.com/view/asterisk?view=rev&rev=101076
Log:
Handle the use_weight variable correctly. The use_weight parameter now indicates
the number of queues which have a weight. It will change either when reloading a queue
or loading a realtime queue. It's change is determined by whether the queue previously
had a weight associated with it and whether it does now. In retrospect, this same change
should probably be applied to 1.4 as well.
Modified:
team/mmichelson/queue-reset/apps/app_queue.c
Modified: team/mmichelson/queue-reset/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/apps/app_queue.c?view=diff&rev=101076&r1=101075&r2=101076
==============================================================================
--- team/mmichelson/queue-reset/apps/app_queue.c (original)
+++ team/mmichelson/queue-reset/apps/app_queue.c Tue Jan 29 17:26:37 2008
@@ -1266,10 +1266,6 @@
q->memberdelay = atoi(val);
} else if (!strcasecmp(param, "weight")) {
q->weight = atoi(val);
- if (q->weight)
- use_weight++;
- /* With Realtime queues, if the last queue using weights is deleted in realtime,
- we will not see any effect on use_weight until next reload. */
} else if (!strcasecmp(param, "timeoutrestart")) {
q->timeoutrestart = ast_true(val);
} else if (!strcasecmp(param, "defaultrule")) {
@@ -1496,6 +1492,7 @@
struct call_queue *q = NULL, tmpq = {
.name = queuename,
};
+ int prev_weight = 0;
/* Find the queue in the in-core list first. */
q = ao2_find(queues, &tmpq, OBJ_POINTER);
@@ -1519,13 +1516,19 @@
return NULL;
}
}
-
- ao2_lock(queues);
+ if (q)
+ prev_weight = q->weight ? 1 : 0;
+
q = find_queue_by_name_rt(queuename, queue_vars, member_config);
if (member_config)
ast_config_destroy(member_config);
if (queue_vars)
ast_variables_destroy(queue_vars);
+ /* update the use_weight value if the queue's has gained or lost a weight */
+ if (!q->weight && prev_weight)
+ use_weight--;
+ if (q->weight && !prev_weight)
+ use_weight++;
ao2_unlock(queues);
} else {
@@ -5004,6 +5007,7 @@
struct ao2_iterator mem_iter;
int queue_reload = mask & QUEUE_RELOAD;
int member_reload = mask & QUEUE_RELOAD_MEMBER;
+ int prev_weight = 0;
struct member *cur;
struct ast_variable *var;
if (!(q = ao2_find(queues, &tmpq, OBJ_POINTER))) {
@@ -5025,8 +5029,10 @@
} else
new = 0;
- if (!new)
+ if (!new) {
ao2_lock(q);
+ prev_weight = q->weight ? 1 : 0;
+ }
/* Check if a queue with this name already exists */
if (q->found) {
ast_log(LOG_WARNING, "Queue '%s' already defined! Skipping!\n", queuename);
@@ -5069,6 +5075,13 @@
if (queue_reload)
queue_set_param(q, var->name, var->value, var->lineno, 1);
}
+ /* At this point, we've determined if the queue has a weight, so update use_weight
+ * as appropriate
+ */
+ if (!q->weight && prev_weight)
+ use_weight--;
+ else if (q->weight && !prev_weight)
+ use_weight++;
/* Free remaining members marked as delme */
if (member_reload) {
@@ -5119,10 +5132,6 @@
}
/* We've made it here, so it looks like we're doing operations on all queues. */
ao2_lock(queues);
-
- /*******************/
- use_weight = 0;/* XXX FIX THIS XXX*/
- /*******************/
/* Mark all queues as dead for the moment if we're reloading queues.
* For clarity, we could just be reloading members, in which case we don't want to mess
More information about the svn-commits
mailing list