[asterisk-commits] mmichelson: trunk r101578 - /trunk/apps/app_queue.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 31 16:04:53 CST 2008
Author: mmichelson
Date: Thu Jan 31 16:04:52 2008
New Revision: 101578
URL: http://svn.digium.com/view/asterisk?view=rev&rev=101578
Log:
A change I made to accommodate the "linear" strategy in trunk caused queue strategies to
not be loaded from realtime queues. This commit fixes that.
Thanks to jmls for pointing this problem out to me on IRC.
This also contains some changes to S_OR where it should be used. Thanks to Qwell for pointing
these out.
Modified:
trunk/apps/app_queue.c
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=101578&r1=101577&r2=101578
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu Jan 31 16:04:52 2008
@@ -1316,7 +1316,7 @@
m->dead = 0; /* Do not delete this one. */
if (paused_str)
m->paused = paused;
- if (strcasecmp(ast_strlen_zero(state_interface) ? interface : state_interface, m->state_interface)) {
+ if (strcasecmp(state_interface, m->state_interface)) {
remove_from_interfaces(m->state_interface);
ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface));
add_to_interfaces(m->state_interface);
@@ -1427,13 +1427,32 @@
/* Create a new queue if an in-core entry does not exist yet. */
if (!q) {
+ struct ast_variable *tmpvar = NULL;
if (!(q = alloc_queue(queuename)))
return NULL;
ao2_lock(q);
clear_queue(q);
q->realtime = 1;
+ /*Before we initialize the queue, we need to set the strategy, so that linear strategy
+ * will allocate the members properly
+ */
+ for (tmpvar = queue_vars; tmpvar; tmpvar = tmpvar->next) {
+ if (strcasecmp(tmpvar->name, "strategy")) {
+ q->strategy = strat2int(tmpvar->value);
+ if (q->strategy < 0) {
+ ast_log(LOG_WARNING, "'%s' isn't a valid strategy for queue '%s', using ringall instead\n",
+ tmpvar->value, q->name);
+ q->strategy = QUEUE_STRATEGY_RINGALL;
+ }
+ break;
+ }
+ }
+ /* We traversed all variables and didn't find a strategy */
+ if (!tmpvar)
+ q->strategy = QUEUE_STRATEGY_RINGALL;
init_queue(q); /* Ensure defaults for all parameters not set explicitly. */
ao2_link(queues, q);
+ ast_variables_destroy(tmpvar);
}
memset(tmpbuf, 0, sizeof(tmpbuf));
@@ -1462,10 +1481,10 @@
while ((interface = ast_category_browse(member_config, interface))) {
rt_handle_member_record(q, interface,
- ast_variable_retrieve(member_config, interface, "membername"),
+ S_OR(ast_variable_retrieve(member_config, interface, "membername"),interface),
ast_variable_retrieve(member_config, interface, "penalty"),
ast_variable_retrieve(member_config, interface, "paused"),
- ast_variable_retrieve(member_config, interface, "state_interface"));
+ S_OR(ast_variable_retrieve(member_config, interface, "state_interface"),interface));
}
/* Delete all realtime members that have been deleted in DB. */
@@ -1576,7 +1595,7 @@
S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface),
ast_variable_retrieve(member_config, interface, "penalty"),
ast_variable_retrieve(member_config, interface, "paused"),
- ast_variable_retrieve(member_config, interface, "state_interface"));
+ S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface));
}
/* Delete all realtime members that have been deleted in DB. */
@@ -4983,7 +5002,7 @@
} else
new = 0;
if (q) {
- const char *tmpvar;
+ const char *tmpvar = NULL;
if (!new)
ao2_lock(q);
/* Check if a queue with this name already exists */
More information about the asterisk-commits
mailing list