[asterisk-commits] irroot: branch irroot/distrotech-customers-trunk r342538 - in /team/irroot/di...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 26 01:06:11 CDT 2011
Author: irroot
Date: Wed Oct 26 01:06:00 2011
New Revision: 342538
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342538
Log:
Multiple revisions 342382,342385,342437,342486,342489
........
r342382 | twilson | 2011-10-25 21:54:17 +0200 (Tue, 25 Oct 2011) | 15 lines
Properly update membercount for reloaded members
Since q->membercount is set to 0 before reloading, it is important
to increment it again for reloaded members as well as added.
(closes issue AST-676)
Review: https://reviewboard.asterisk.org/r/1541/
........
Merged revisions 342380 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 342381 from http://svn.asterisk.org/svn/asterisk/branches/10
........
r342385 | twilson | 2011-10-25 22:07:59 +0200 (Tue, 25 Oct 2011) | 27 lines
Simplify queue membercount code
Despite an ominous sounding comment stating that membercount was for "logged
in" members only and thus we couldn't use ao2_container_count(), I could not
find a single place in the code where that seemed to be accurate. The only time
we decremented membercount was when we were marking something dead or actually
removing it. The only places we incremented it were either after ao2_link(), or
trying to correct for having set it to 0 during a reload. In every case where
we were correcting the value, it seemed that we were trying to make the count
actually match what ao2_container_count() would return. The only place I could
find where we made a determination about something being "logged in" or not, we
didn't trust the membercount, but instead looked at devicestate, paused, etc.
This patch removes membercount, replaces its use with ao2_container_count, and
manually adds the results of ao2_container_count to a "membercount" field for
ast_data queue query results. This patch also would fix AST-676, but as it is
slightly riskier than the previously committed fix, the two commits have been
made separately.
Reivew: https://reviewboard.asterisk.org/r/1541/
........
Merged revisions 342383 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 342384 from http://svn.asterisk.org/svn/asterisk/branches/10
........
r342437 | twilson | 2011-10-25 23:11:14 +0200 (Tue, 25 Oct 2011) | 10 lines
Use int for storing ao2_container_count instad of size_t
AST-676
........
Merged revisions 342435 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 342436 from http://svn.asterisk.org/svn/asterisk/branches/10
........
r342486 | rmudgett | 2011-10-25 23:54:31 +0200 (Tue, 25 Oct 2011) | 18 lines
Change D-channel warning to be less confusing on non-NFAS setups.
The "No D-channels available! Using Primary channel as D-channel anyway!"
WARNING message has been confusing on non-NFAS setups. The message refers
to things that are NFAS specific.
* Changed the warning to several different warnings to be more accurate
for the situation and less confusing as a result:
"No D-channels up! Switching selected D-channel from X to Y.",
"No D-channels up!", and
"D-channel is down!".
........
Merged revisions 342484 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 342485 from http://svn.asterisk.org/svn/asterisk/branches/10
........
r342489 | rmudgett | 2011-10-26 00:06:43 +0200 (Wed, 26 Oct 2011) | 13 lines
Check fopen return value for ao2 reference debug output.
Reported by: wdoekes
Patched by: wdoekes
Review: https://reviewboard.asterisk.org/r/1539/
........
Merged revisions 342487 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 342488 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 342382,342385,342437,342486,342489 from http://svn.asterisk.org/svn/asterisk/trunk
Modified:
team/irroot/distrotech-customers-trunk/ (props changed)
team/irroot/distrotech-customers-trunk/apps/app_queue.c
team/irroot/distrotech-customers-trunk/channels/sig_pri.c
team/irroot/distrotech-customers-trunk/main/astobj2.c
Propchange: team/irroot/distrotech-customers-trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.
Propchange: team/irroot/distrotech-customers-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Oct 26 01:06:00 2011
@@ -1,1 +1,1 @@
-/trunk:1-342341
+/trunk:1-342537
Modified: team/irroot/distrotech-customers-trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/apps/app_queue.c?view=diff&rev=342538&r1=342537&r2=342538
==============================================================================
--- team/irroot/distrotech-customers-trunk/apps/app_queue.c (original)
+++ team/irroot/distrotech-customers-trunk/apps/app_queue.c Wed Oct 26 01:06:00 2011
@@ -1196,12 +1196,6 @@
int autofill; /*!< Ignore the head call status and ring an available agent */
struct ao2_container *members; /*!< Head of the list of members */
- /*!
- * \brief Number of members _logged in_
- * \note There will be members in the members container that are not logged
- * in, so this can not simply be replaced with ao2_container_count().
- */
- int membercount;
struct queue_ent *head; /*!< Head of the list of callers */
AST_LIST_ENTRY(call_queue) list; /*!< Next call queue */
AST_LIST_HEAD_NOLOCK(, penalty_rule) rules; /*!< The list of penalty rules to invoke */
@@ -2264,8 +2258,6 @@
}
ao2_link(q->members, m);
ao2_ref(m, -1);
- m = NULL;
- q->membercount++;
}
}
@@ -2279,7 +2271,6 @@
while ((cur = ao2_iterator_next(&mem_iter))) {
if (all || !cur->dynamic) {
ao2_unlink(q->members, cur);
- q->membercount--;
}
ao2_ref(cur, -1);
}
@@ -2381,7 +2372,6 @@
ao2_lock(q);
clear_queue(q);
q->realtime = 1;
- q->membercount = 0;
/*Before we initialize the queue, we need to set the strategy, so that linear strategy
* will allocate the members properly
*/
@@ -2422,11 +2412,9 @@
queue_set_param(q, tmp_name, v->value, -1, 0);
}
- /* Temporarily set realtime members dead so we can detect deleted ones.
- * Also set the membercount correctly for realtime*/
+ /* Temporarily set realtime members dead so we can detect deleted ones. */
mem_iter = ao2_iterator_init(q->members, 0);
while ((m = ao2_iterator_next(&mem_iter))) {
- q->membercount++;
if (m->realtime) {
m->dead = 1;
}
@@ -2448,7 +2436,6 @@
ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", "");
}
ao2_unlink(q->members, m);
- q->membercount--;
}
ao2_ref(m, -1);
}
@@ -2566,7 +2553,6 @@
ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", "");
}
ao2_unlink(q->members, m);
- q->membercount--;
}
ao2_ref(m, -1);
}
@@ -4274,7 +4260,8 @@
static int calc_metric(struct call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct callattempt *tmp)
{
/* disregarding penalty on too few members? */
- unsigned char usepenalty = (q->membercount <= q->penaltymemberslimit) ? 0 : 1;
+ int membercount = ao2_container_count(q->members);
+ unsigned char usepenalty = (membercount <= q->penaltymemberslimit) ? 0 : 1;
if (usepenalty) {
if ((qe->max_penalty && (mem->penalty > qe->max_penalty)) ||
@@ -4283,7 +4270,7 @@
}
} else {
ast_debug(1, "Disregarding penalty, %d members and %d in penaltymemberslimit.\n",
- q->membercount, q->penaltymemberslimit);
+ membercount, q->penaltymemberslimit);
}
switch (q->strategy) {
@@ -4626,7 +4613,7 @@
if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY || qe->parent->strategy == QUEUE_STRATEGY_LINEAR || qe->parent->strategy == QUEUE_STRATEGY_RRORDERED)
(*tries)++;
else
- *tries = qe->parent->membercount;
+ *tries = ao2_container_count(qe->parent->members);
*noption = 1;
break;
case 'i':
@@ -5414,7 +5401,6 @@
queue_t_unref(q, "Interface wasn't dynamic, expiring temporary reference");
return RES_NOT_DYNAMIC;
}
- q->membercount--;
manager_event(EVENT_FLAG_AGENT, "QueueMemberRemoved",
"Queue: %s\r\n"
"Location: %s\r\n"
@@ -5461,7 +5447,6 @@
if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface))) {
new_member->dynamic = 1;
ao2_link(q->members, new_member);
- q->membercount++;
ao2_lock(new_member->device);
manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded",
"Queue: %s\r\n"
@@ -6292,7 +6277,7 @@
}
/* exit after 'timeout' cycle if 'n' option enabled */
- if (noption && tries >= qe.parent->membercount) {
+ if (noption && tries >= ao2_container_count(qe.parent->members)) {
ast_verb(3, "Exiting on time-out cycle\n");
ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
record_abandoned(&qe);
@@ -6513,7 +6498,7 @@
}
ao2_iterator_destroy(&mem_iter);
} else if (!strcasecmp(args.option, "count") || ast_strlen_zero(args.option)) {
- count = q->membercount;
+ count = ao2_container_count(q->members);
} else if (!strcasecmp(args.option, "penalty") && !ast_strlen_zero(args.interface) &&
((m = interface_exists(q, args.interface)))) {
count = m->penalty;
@@ -7007,8 +6992,6 @@
if (cur) {
ao2_ref(cur, -1);
- } else {
- q->membercount++;
}
}
@@ -7024,18 +7007,10 @@
static int kill_dead_members(void *obj, void *arg, int flags)
{
struct member *member = obj;
- struct call_queue *q = arg;
if (!member->delme) {
- if (member->dynamic) {
- /* dynamic members were not counted toward the member count
- * when reloading members from queues.conf, so we do that here
- */
- q->membercount++;
- }
return 0;
} else {
- q->membercount--;
return CMP_MATCH;
}
}
@@ -7111,7 +7086,6 @@
init_queue(q);
}
if (member_reload) {
- q->membercount = 0;
ao2_callback(q->members, OBJ_NODATA, mark_member_dead, NULL);
}
for (var = ast_variable_browse(cfg, queuename); var; var = var->next) {
@@ -8499,8 +8473,7 @@
MEMBER(call_queue, rrpos, AST_DATA_INTEGER) \
MEMBER(call_queue, memberdelay, AST_DATA_INTEGER) \
MEMBER(call_queue, autofill, AST_DATA_INTEGER) \
- MEMBER(call_queue, members, AST_DATA_CONTAINER) \
- MEMBER(call_queue, membercount, AST_DATA_INTEGER)
+ MEMBER(call_queue, members, AST_DATA_CONTAINER)
AST_DATA_STRUCTURE(call_queue, DATA_EXPORT_CALL_QUEUE);
@@ -8574,6 +8547,7 @@
ast_data_add_structure(call_queue, data_queue, queue);
ast_data_add_str(data_queue, "strategy", int2strat(queue->strategy));
+ ast_data_add_int(data_queue, "membercount", ao2_container_count(queue->members));
/* announce position */
enum_node = ast_data_add_node(data_queue, "announceposition");
Modified: team/irroot/distrotech-customers-trunk/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/channels/sig_pri.c?view=diff&rev=342538&r1=342537&r2=342538
==============================================================================
--- team/irroot/distrotech-customers-trunk/channels/sig_pri.c (original)
+++ team/irroot/distrotech-customers-trunk/channels/sig_pri.c Wed Oct 26 01:06:00 2011
@@ -1012,7 +1012,7 @@
return 0;
}
-static char *pri_order(int level)
+static const char *pri_order(int level)
{
switch (level) {
case 0:
@@ -1042,37 +1042,74 @@
return -1;
}
-static int pri_find_dchan(struct sig_pri_span *pri)
-{
+static void pri_find_dchan(struct sig_pri_span *pri)
+{
+ struct pri *old;
int oldslot = -1;
- struct pri *old;
int newslot = -1;
- int x;
+ int idx;
+
old = pri->pri;
- for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) {
- if ((pri->dchanavail[x] == DCHAN_AVAILABLE) && (newslot < 0))
- newslot = x;
- if (pri->dchans[x] == old) {
- oldslot = x;
- }
- }
- if (newslot < 0) {
- newslot = 0;
- /* This is annoying to see on non persistent layer 2 connections. Let's not complain in that case */
- if (pri->sig != SIG_BRI_PTMP && !pri->no_d_channels) {
- pri->no_d_channels = 1;
- ast_log(LOG_WARNING,
- "Span %d: No D-channels available! Using Primary channel as D-channel anyway!\n",
- pri->span);
+ for (idx = 0; idx < SIG_PRI_NUM_DCHANS; ++idx) {
+ if (!pri->dchans[idx]) {
+ /* No more D channels defined on the span. */
+ break;
+ }
+ if (pri->dchans[idx] == old) {
+ oldslot = idx;
+ }
+ if (newslot < 0 && pri->dchanavail[idx] == DCHAN_AVAILABLE) {
+ newslot = idx;
+ }
+ }
+ /* At this point, idx is a count of how many D-channels are defined on the span. */
+
+ if (1 < idx) {
+ /* We have several D-channels defined on the span. (NFAS PRI setup) */
+ if (newslot < 0) {
+ /* No D-channels available. Default to the primary D-channel. */
+ newslot = 0;
+
+ if (!pri->no_d_channels) {
+ pri->no_d_channels = 1;
+ if (old && oldslot != newslot) {
+ ast_log(LOG_WARNING,
+ "Span %d: No D-channels up! Switching selected D-channel from %s to %s.\n",
+ pri->span, pri_order(oldslot), pri_order(newslot));
+ } else {
+ ast_log(LOG_WARNING, "Span %d: No D-channels up!\n", pri->span);
+ }
+ }
+ } else {
+ pri->no_d_channels = 0;
+ }
+ if (old && oldslot != newslot) {
+ ast_log(LOG_NOTICE,
+ "Switching selected D-channel from %s (fd %d) to %s (fd %d)!\n",
+ pri_order(oldslot), pri->fds[oldslot],
+ pri_order(newslot), pri->fds[newslot]);
}
} else {
- pri->no_d_channels = 0;
- }
- if (old && (oldslot != newslot))
- ast_log(LOG_NOTICE, "Switching from d-channel fd %d to fd %d!\n",
- pri->fds[oldslot], pri->fds[newslot]);
+ if (newslot < 0) {
+ /* The only D-channel is not up. */
+ newslot = 0;
+
+ if (!pri->no_d_channels) {
+ pri->no_d_channels = 1;
+
+ /*
+ * This is annoying to see on non-persistent layer 2
+ * connections. Let's not complain in that case.
+ */
+ if (pri->sig != SIG_BRI_PTMP) {
+ ast_log(LOG_WARNING, "Span %d: D-channel is down!\n", pri->span);
+ }
+ }
+ } else {
+ pri->no_d_channels = 0;
+ }
+ }
pri->pri = pri->dchans[newslot];
- return 0;
}
/*!
@@ -1936,8 +1973,9 @@
void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri)
{
pri->dchanavail[index] &= ~(DCHAN_NOTINALARM | DCHAN_UP);
- if (!before_start_pri)
+ if (!before_start_pri) {
pri_find_dchan(pri);
+ }
}
void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri)
@@ -5601,7 +5639,9 @@
switch (e->e) {
case PRI_EVENT_DCHAN_UP:
pri->no_d_channels = 0;
- if (!pri->pri) pri_find_dchan(pri);
+ if (!pri->pri) {
+ pri_find_dchan(pri);
+ }
/* Note presense of D-channel */
time(&pri->lastreset);
@@ -5624,8 +5664,10 @@
pri_find_dchan(pri);
if (!pri_is_up(pri)) {
if (pri->sig == SIG_BRI_PTMP) {
- /* For PTMP connections with non persistent layer 2 we want
- * to *not* declare inalarm unless there actually is an alarm */
+ /*
+ * For PTMP connections with non-persistent layer 2 we want to
+ * *not* declare inalarm unless there actually is an alarm.
+ */
break;
}
/* Hangup active channels and put them in alarm mode */
Modified: team/irroot/distrotech-customers-trunk/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/main/astobj2.c?view=diff&rev=342538&r1=342537&r2=342538
==============================================================================
--- team/irroot/distrotech-customers-trunk/main/astobj2.c (original)
+++ team/irroot/distrotech-customers-trunk/main/astobj2.c Wed Oct 26 01:06:00 2011
@@ -210,14 +210,19 @@
return -1;
if (delta != 0) {
- FILE *refo = fopen(REF_FILE,"a");
- fprintf(refo, "%p %s%d %s:%d:%s (%s) [@%d]\n", user_data, (delta<0? "":"+"), delta, file, line, funcname, tag, obj ? obj->priv_data.ref_counter : -1);
- fclose(refo);
+ FILE *refo = fopen(REF_FILE, "a");
+ if (refo) {
+ fprintf(refo, "%p %s%d %s:%d:%s (%s) [@%d]\n", user_data, (delta < 0 ? "" : "+"),
+ delta, file, line, funcname, tag, obj ? obj->priv_data.ref_counter : -1);
+ fclose(refo);
+ }
}
if (obj->priv_data.ref_counter + delta == 0 && obj->priv_data.destructor_fn != NULL) { /* this isn't protected with lock; just for o/p */
- FILE *refo = fopen(REF_FILE,"a");
- fprintf(refo, "%p **call destructor** %s:%d:%s (%s)\n", user_data, file, line, funcname, tag);
+ FILE *refo = fopen(REF_FILE, "a");
+ if (refo) {
+ fprintf(refo, "%p **call destructor** %s:%d:%s (%s)\n", user_data, file, line, funcname, tag);
fclose(refo);
+ }
}
return internal_ao2_ref(user_data, delta);
}
@@ -319,14 +324,13 @@
{
/* allocation */
void *obj;
- FILE *refo = ref_debug ? fopen(REF_FILE,"a") : NULL;
+ FILE *refo;
if ((obj = internal_ao2_alloc(data_size, destructor_fn, file, line, funcname)) == NULL) {
- fclose(refo);
- return NULL;
- }
-
- if (refo) {
+ return NULL;
+ }
+
+ if (ref_debug && (refo = fopen(REF_FILE, "a"))) {
fprintf(refo, "%p =1 %s:%d:%s (%s)\n", obj, file, line, funcname, tag);
fclose(refo);
}
More information about the asterisk-commits
mailing list