[asterisk-commits] tilghman: branch tilghman/compiler_attributes r130172 - in /team/tilghman/com...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jul 11 13:58:47 CDT 2008
Author: tilghman
Date: Fri Jul 11 13:58:47 2008
New Revision: 130172
URL: http://svn.digium.com/view/asterisk?view=rev&rev=130172
Log:
Merged revisions 130126,130129,130145,130167,130170 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r130126 | tilghman | 2008-07-11 12:29:24 -0500 (Fri, 11 Jul 2008) | 17 lines
Merged revisions 130102 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r130102 | tilghman | 2008-07-11 11:50:42 -0500 (Fri, 11 Jul 2008) | 9 lines
Pass the devicestate from an underlying channel up through the Agent channel.
This should make the Agent always report the correct device state, even when
the underlying channel is used for other purposes.
(closes issue #12773)
Reported by: davidw
Patches:
20080710__bug12773.diff.txt uploaded by Corydon76 (license 14)
Tested by: davidw
........
................
r130129 | bbryant | 2008-07-11 13:09:35 -0500 (Fri, 11 Jul 2008) | 8 lines
Janitor patch to change uses of sizeof to ARRAY_LEN
(closes issue #13054)
Reported by: pabelanger
Patches:
ARRAY_LEN.patch2 uploaded by pabelanger (license 224)
Tested by: seanbright
................
r130145 | murf | 2008-07-11 13:24:31 -0500 (Fri, 11 Jul 2008) | 40 lines
(closes issue #13041)
Reported by: eliel
Tested by: murf
(closes issue #12960)
Reported by: mnicholson
In this 'omnibus' fix, I **think** I solved both
the problem in 13041, where unloading pbx_ael.so
caused crashes, or incomplete removal of previous
registrar'ed entries. And I added code to completely
remove all includes, switches, and ignorepats that
had a matching registrar entry, which should
appease 12960.
I also added a lot of seemingly useless brackets
around single statement if's, which helped debug
so much that I'm leaving them there.
I added a routine to check the correlation between
the extension tree lists and the hashtab
tables. It can be amazingly helpful when you have
lots of dialplan stuff, and need to narrow
down where a problem is occurring. It's ifdef'd
out by default.
I cleaned up the code around the new CIDmatch code.
It was leaving hanging extens with bad ptrs, getting confused
over which objects to remove, etc. I tightened
up the code and changed the call to remove_exten
in the merge_and_delete code.
I added more conditions to check for empty context
worthy of deletion. It's not empty if there are
any includes, switches, or ignorepats present.
If I've missed anything, please re-open this bug,
and be prepared to supply example dialplan code.
................
r130167 | seanbright | 2008-07-11 13:32:26 -0500 (Fri, 11 Jul 2008) | 1 line
Missed one. Formatting only.
................
r130170 | tilghman | 2008-07-11 13:52:42 -0500 (Fri, 11 Jul 2008) | 15 lines
Merged revisions 130169 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r130169 | tilghman | 2008-07-11 13:51:56 -0500 (Fri, 11 Jul 2008) | 7 lines
Ensure that a destination callno of 0 will not match for frames that do not
start a dialog (new, lagrq, and ping).
(closes issue #12963)
Reported by: russellb
Patches:
chan_iax2_dup_new_fix4.patch uploaded by jpgrayson (license 492)
........
................
Modified:
team/tilghman/compiler_attributes/ (props changed)
team/tilghman/compiler_attributes/apps/app_chanspy.c
team/tilghman/compiler_attributes/apps/app_milliwatt.c
team/tilghman/compiler_attributes/apps/app_minivm.c
team/tilghman/compiler_attributes/channels/chan_agent.c
team/tilghman/compiler_attributes/channels/chan_dahdi.c
team/tilghman/compiler_attributes/channels/chan_gtalk.c
team/tilghman/compiler_attributes/channels/chan_iax2.c
team/tilghman/compiler_attributes/channels/chan_jingle.c
team/tilghman/compiler_attributes/channels/chan_sip.c
team/tilghman/compiler_attributes/channels/chan_skinny.c
team/tilghman/compiler_attributes/codecs/codec_dahdi.c
team/tilghman/compiler_attributes/codecs/codec_g722.c
team/tilghman/compiler_attributes/codecs/codec_resample.c
team/tilghman/compiler_attributes/main/abstract_jb.c
team/tilghman/compiler_attributes/main/asterisk.c
team/tilghman/compiler_attributes/main/cli.c
team/tilghman/compiler_attributes/main/dsp.c
team/tilghman/compiler_attributes/main/pbx.c
team/tilghman/compiler_attributes/main/threadstorage.c
team/tilghman/compiler_attributes/main/utils.c
team/tilghman/compiler_attributes/pbx/dundi-parser.c
team/tilghman/compiler_attributes/utils/astman.c
Propchange: team/tilghman/compiler_attributes/
------------------------------------------------------------------------------
automerge = *
Propchange: team/tilghman/compiler_attributes/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/tilghman/compiler_attributes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jul 11 13:58:47 2008
@@ -1,1 +1,1 @@
-/trunk:1-130097
+/trunk:1-130171
Modified: team/tilghman/compiler_attributes/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/apps/app_chanspy.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/apps/app_chanspy.c (original)
+++ team/tilghman/compiler_attributes/apps/app_chanspy.c Fri Jul 11 13:58:47 2008
@@ -754,12 +754,12 @@
if (mygroup) {
dup_mygroup = ast_strdupa(mygroup);
num_mygroups = ast_app_separate_args(dup_mygroup, ':', mygroups,
- sizeof(mygroups) / sizeof(mygroups[0]));
+ ARRAY_LEN(mygroups));
if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
dup_group = ast_strdupa(group);
num_groups = ast_app_separate_args(dup_group, ':', groups,
- sizeof(groups) / sizeof(groups[0]));
+ ARRAY_LEN(groups));
}
for (y = 0; y < num_mygroups; y++) {
Modified: team/tilghman/compiler_attributes/apps/app_milliwatt.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/apps/app_milliwatt.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/apps/app_milliwatt.c (original)
+++ team/tilghman/compiler_attributes/apps/app_milliwatt.c Fri Jul 11 13:58:47 2008
@@ -64,7 +64,7 @@
static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int samples)
{
unsigned char buf[AST_FRIENDLY_OFFSET + 640];
- const int maxsamples = sizeof (buf) / sizeof (buf[0]);
+ const int maxsamples = ARRAY_LEN(buf);
int i, *indexp = (int *) data;
struct ast_frame wf = {
.frametype = AST_FRAME_VOICE,
Modified: team/tilghman/compiler_attributes/apps/app_minivm.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/apps/app_minivm.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/apps/app_minivm.c (original)
+++ team/tilghman/compiler_attributes/apps/app_minivm.c Fri Jul 11 13:58:47 2008
@@ -1641,7 +1641,7 @@
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
- argc = ast_app_separate_args(tmpptr, ',', argv, sizeof(argv) / sizeof(argv[0]));
+ argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
if (argc == 2 && !ast_strlen_zero(argv[1]))
template = argv[1];
@@ -1721,7 +1721,7 @@
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
- argc = ast_app_separate_args(tmp, ',', argv, sizeof(argv) / sizeof(argv[0]));
+ argc = ast_app_separate_args(tmp, ',', argv, ARRAY_LEN(argv));
if (argc == 2) {
if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) {
return -1;
@@ -1783,7 +1783,7 @@
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
- argc = ast_app_separate_args(tmpptr, ',', argv, sizeof(argv) / sizeof(argv[0]));
+ argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
if (argc == 2) {
if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1]))
@@ -2005,7 +2005,7 @@
ast_log(LOG_ERROR, "Out of memory\n");
error = TRUE;
} else
- argc = ast_app_separate_args(tmpptr, ',', argv, sizeof(argv) / sizeof(argv[0]));
+ argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
}
if (argc <=1) {
Modified: team/tilghman/compiler_attributes/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/channels/chan_agent.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/channels/chan_agent.c (original)
+++ team/tilghman/compiler_attributes/channels/chan_agent.c Fri Jul 11 13:58:47 2008
@@ -67,6 +67,7 @@
#include "asterisk/devicestate.h"
#include "asterisk/monitor.h"
#include "asterisk/stringfields.h"
+#include "asterisk/event.h"
static const char tdesc[] = "Call Agent Proxy Channel";
static const char config[] = "agents.conf";
@@ -147,6 +148,7 @@
static char savecallsin[AST_MAX_BUF] = "";
static int updatecdr = 0;
static char beep[AST_MAX_BUF] = "beep";
+struct ast_event_sub *agent_devicestate_sub = NULL;
#define GETAGENTBYCALLERID "AGENTBYCALLERID"
@@ -171,6 +173,7 @@
char agent[AST_MAX_AGENT]; /*!< Agent ID */
char password[AST_MAX_AGENT]; /*!< Password for Agent login */
char name[AST_MAX_AGENT];
+ int inherited_devicestate; /*!< Does the underlying channel have a devicestate to pass? */
ast_mutex_t app_lock; /**< Synchronization between owning applications */
volatile pthread_t owning_app; /**< Owning application thread id */
volatile int app_sleep_cond; /**< Sleep condition for the login app */
@@ -261,6 +264,48 @@
.set_base_channel = agent_set_base_channel,
};
+static void agent_devicestate_cb(const struct ast_event *event, void *unused)
+{
+ int res, i;
+ struct agent_pvt *p;
+ char basename[AST_CHANNEL_NAME], *tmp;
+ const char *device;
+ enum ast_device_state state;
+
+ /* Try to be safe, but don't deadlock */
+ for (i = 0; i < 10; i++) {
+ if ((res = AST_LIST_TRYLOCK(&agents)) == 0) {
+ break;
+ }
+ }
+ if (res) {
+ return;
+ }
+
+ state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
+ device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
+
+ if (ast_strlen_zero(device)) {
+ return;
+ }
+
+ AST_LIST_TRAVERSE(&agents, p, list) {
+ ast_mutex_lock(&p->lock);
+ if (p->chan) {
+ ast_copy_string(basename, p->chan->name, sizeof(basename));
+ if ((tmp = strrchr(basename, '-'))) {
+ *tmp = '\0';
+ }
+ if (strcasecmp(p->chan->name, device) == 0 || strcasecmp(basename, device) == 0) {
+ p->inherited_devicestate = state;
+ ast_device_state_changed("Agent/%s", p->agent);
+ }
+ }
+ ast_mutex_unlock(&p->lock);
+ }
+ AST_LIST_UNLOCK(&agents);
+}
+
/*!
* Adds an agent to the global list of agents.
*
@@ -323,6 +368,7 @@
p->app_sleep_cond = 1;
p->group = group;
p->pending = pending;
+ p->inherited_devicestate = -1;
AST_LIST_INSERT_TAIL(&agents, p, list);
}
@@ -466,6 +512,7 @@
p->lastdisc = ast_tvadd(ast_tvnow(), ast_samp2tv(p->wrapuptime, 1000));
}
p->chan = NULL;
+ p->inherited_devicestate = -1;
p->acknowledged = 0;
}
} else {
@@ -680,6 +727,7 @@
} else {
/* Agent hung-up */
p->chan = NULL;
+ p->inherited_devicestate = -1;
}
if (!res) {
@@ -800,6 +848,7 @@
/* Recognize the hangup and pass it along immediately */
ast_hangup(p->chan);
p->chan = NULL;
+ p->inherited_devicestate = -1;
}
ast_debug(1, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
if ((p->deferlogoff) || (howlong && p->autologoff && (howlong > p->autologoff))) {
@@ -1523,6 +1572,7 @@
set_agentbycallerid(p->logincallerid, NULL);
p->loginchan[0] ='\0';
p->logincallerid[0] = '\0';
+ p->inherited_devicestate = -1;
ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Agent/%s", p->agent);
if (persistent_agents)
dump_agents();
@@ -2078,8 +2128,10 @@
if (res && p->owner)
ast_log(LOG_WARNING, "Huh? We broke out when there was still an owner?\n");
/* Log us off if appropriate */
- if (p->chan == chan)
+ if (p->chan == chan) {
p->chan = NULL;
+ p->inherited_devicestate = -1;
+ }
p->acknowledged = 0;
logintime = time(NULL) - p->loginstart;
p->loginstart = 0;
@@ -2292,6 +2344,8 @@
if (p->owner) {
if (res != AST_DEVICE_INUSE)
res = AST_DEVICE_BUSY;
+ } else if (p->inherited_devicestate > -1) {
+ res = p->inherited_devicestate;
} else {
if (res == AST_DEVICE_BUSY)
res = AST_DEVICE_INUSE;
@@ -2433,6 +2487,8 @@
/* Dialplan Functions */
ast_custom_function_register(&agent_function);
+ agent_devicestate_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, agent_devicestate_cb, NULL);
+
return AST_MODULE_LOAD_SUCCESS;
}
@@ -2450,6 +2506,8 @@
struct agent_pvt *p;
/* First, take us out of the channel loop */
ast_channel_unregister(&agent_tech);
+ /* Delete devicestate subscription */
+ agent_devicestate_sub = ast_event_unsubscribe(agent_devicestate_sub);
/* Unregister dialplan functions */
ast_custom_function_unregister(&agent_function);
/* Unregister CLI commands */
Modified: team/tilghman/compiler_attributes/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/channels/chan_dahdi.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/channels/chan_dahdi.c (original)
+++ team/tilghman/compiler_attributes/channels/chan_dahdi.c Fri Jul 11 13:58:47 2008
@@ -1357,7 +1357,7 @@
static char *event2str(int event)
{
static char buf[256];
- if ((event < (sizeof(events) / sizeof(events[0]))) && (event > -1))
+ if ((event < (ARRAY_LEN(events))) && (event > -1))
return events[event];
sprintf(buf, "Event %d", event); /* safe */
return buf;
@@ -6925,7 +6925,7 @@
break;
/* Increment the ringT counter so we can match it against
values in chan_dahdi.conf for distinctive ring */
- if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0])))
+ if (++receivedRingT == ARRAY_LEN(curRingData))
break;
} else if (i & DAHDI_IOMUX_READ) {
res = read(p->subs[index].zfd, buf, sizeof(buf));
@@ -7084,7 +7084,7 @@
break;
/* Increment the ringT counter so we can match it against
values in chan_dahdi.conf for distinctive ring */
- if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0])))
+ if (++receivedRingT == ARRAY_LEN(curRingData))
break;
} else if (i & DAHDI_IOMUX_READ) {
res = read(p->subs[index].zfd, buf, sizeof(buf));
@@ -7145,7 +7145,7 @@
break;
/* Increment the ringT counter so we can match it against
values in chan_dahdi.conf for distinctive ring */
- if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0])))
+ if (++receivedRingT == ARRAY_LEN(curRingData))
break;
} else if (i & DAHDI_IOMUX_READ) {
res = read(p->subs[index].zfd, buf, sizeof(buf));
@@ -13701,7 +13701,7 @@
unsigned int param_count;
unsigned int x;
- if (!(param_count = ast_app_separate_args(parse, ',', params, sizeof(params) / sizeof(params[0]))))
+ if (!(param_count = ast_app_separate_args(parse, ',', params, ARRAY_LEN(params)))
return;
memset(&confp->chan.echocancel, 0, sizeof(confp->chan.echocancel));
@@ -14809,7 +14809,7 @@
ast_cli_register_multiple(dahdi_pri_cli, sizeof(dahdi_pri_cli) / sizeof(struct ast_cli_entry));
#endif
#ifdef HAVE_SS7
- ast_cli_register_multiple(dahdi_ss7_cli, sizeof(dahdi_ss7_cli) / sizeof(dahdi_ss7_cli[0]));
+ ast_cli_register_multiple(dahdi_ss7_cli, ARRAY_LEN(dahdi_ss7_cli));
#endif
ast_cli_register_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry));
Modified: team/tilghman/compiler_attributes/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/channels/chan_gtalk.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/channels/chan_gtalk.c (original)
+++ team/tilghman/compiler_attributes/channels/chan_gtalk.c Fri Jul 11 13:58:47 2008
@@ -2012,7 +2012,7 @@
}
ast_rtp_proto_register(>alk_rtp);
- ast_cli_register_multiple(gtalk_cli, sizeof(gtalk_cli) / sizeof(gtalk_cli[0]));
+ ast_cli_register_multiple(gtalk_cli, ARRAY_LEN(gtalk_cli));
/* Make sure we can register our channel type */
if (ast_channel_register(>alk_tech)) {
@@ -2032,7 +2032,7 @@
static int unload_module(void)
{
struct gtalk_pvt *privates = NULL;
- ast_cli_unregister_multiple(gtalk_cli, sizeof(gtalk_cli) / sizeof(gtalk_cli[0]));
+ ast_cli_unregister_multiple(gtalk_cli, ARRAY_LEN(gtalk_cli));
/* First, take us out of the channel loop */
ast_channel_unregister(>alk_tech);
ast_rtp_proto_unregister(>alk_rtp);
Modified: team/tilghman/compiler_attributes/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/channels/chan_iax2.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/channels/chan_iax2.c (original)
+++ team/tilghman/compiler_attributes/channels/chan_iax2.c Fri Jul 11 13:58:47 2008
@@ -8047,12 +8047,21 @@
* Discussed in the following thread:
* http://lists.digium.com/pipermail/asterisk-dev/2008-May/033217.html
*/
- if (f.frametype != AST_FRAME_IAX ||
- (f.subclass != IAX_COMMAND_NEW &&
- f.subclass != IAX_COMMAND_PING &&
- f.subclass != IAX_COMMAND_LAGRQ)) {
- /* Get the destination call number */
- dcallno = ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS;
+
+ /* Get the destination call number */
+ dcallno = ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS;
+
+ if (f.frametype == AST_FRAME_IAX &&
+ (f.subclass == IAX_COMMAND_NEW ||
+ f.subclass == IAX_COMMAND_PING ||
+ f.subclass == IAX_COMMAND_LAGRQ)) {
+ dcallno = 0;
+ } else if (!dcallno) {
+ /* All other full-frames must have a non-zero dcallno,
+ * We silently drop this frame since it cannot be a
+ * valid match to an existing call session.
+ */
+ return 1;
}
if ((f.frametype == AST_FRAME_IAX) && ((f.subclass == IAX_COMMAND_NEW) || (f.subclass == IAX_COMMAND_REGREQ) ||
(f.subclass == IAX_COMMAND_POKE) || (f.subclass == IAX_COMMAND_FWDOWNL) ||
Modified: team/tilghman/compiler_attributes/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/channels/chan_jingle.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/channels/chan_jingle.c (original)
+++ team/tilghman/compiler_attributes/channels/chan_jingle.c Fri Jul 11 13:58:47 2008
@@ -1879,7 +1879,7 @@
}
ast_rtp_proto_register(&jingle_rtp);
- ast_cli_register_multiple(jingle_cli, sizeof(jingle_cli) / sizeof(jingle_cli[0]));
+ ast_cli_register_multiple(jingle_cli, ARRAY_LEN(jingle_cli));
/* Make sure we can register our channel type */
if (ast_channel_register(&jingle_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -1898,7 +1898,7 @@
static int unload_module(void)
{
struct jingle_pvt *privates = NULL;
- ast_cli_unregister_multiple(jingle_cli, sizeof(jingle_cli) / sizeof(jingle_cli[0]));
+ ast_cli_unregister_multiple(jingle_cli, ARRAY_LEN(jingle_cli));
/* First, take us out of the channel loop */
ast_channel_unregister(&jingle_tech);
ast_rtp_proto_unregister(&jingle_rtp);
Modified: team/tilghman/compiler_attributes/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/channels/chan_sip.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/channels/chan_sip.c (original)
+++ team/tilghman/compiler_attributes/channels/chan_sip.c Fri Jul 11 13:58:47 2008
@@ -2601,7 +2601,7 @@
if (ast_strlen_zero(msg))
return 0;
- for (i = 1; i < (sizeof(sip_methods) / sizeof(sip_methods[0])) && !res; i++) {
+ for (i = 1; i < ARRAY_LEN(sip_methods) && !res; i++) {
if (method_match(i, msg))
res = sip_methods[i].id;
}
@@ -13641,7 +13641,7 @@
{
int i;
- for (i = 1; (i < (sizeof(subscription_types) / sizeof(subscription_types[0]))); i++) {
+ for (i = 1; i < ARRAY_LEN(subscription_types); i++) {
if (subscription_types[i].type == subtype) {
return subscription_types[i].text;
}
@@ -13654,7 +13654,7 @@
{
int i;
- for (i = 1; (i < (sizeof(subscription_types) / sizeof(subscription_types[0]))); i++) {
+ for (i = 1; i < ARRAY_LEN(subscription_types); i++) {
if (subscription_types[i].type == subtype) {
return &subscription_types[i];
}
Modified: team/tilghman/compiler_attributes/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/channels/chan_skinny.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/channels/chan_skinny.c (original)
+++ team/tilghman/compiler_attributes/channels/chan_skinny.c Fri Jul 11 13:58:47 2008
@@ -6425,7 +6425,7 @@
{
int res = 0;
- for (; res < (sizeof(soft_key_template_default) / sizeof(soft_key_template_default[0])); res++) {
+ for (; res < ARRAY_LEN(soft_key_template_default); res++) {
soft_key_template_default[res].softKeyEvent = htolel(soft_key_template_default[res].softKeyEvent);
}
/* load and parse config */
Modified: team/tilghman/compiler_attributes/codecs/codec_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/codecs/codec_dahdi.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/codecs/codec_dahdi.c (original)
+++ team/tilghman/compiler_attributes/codecs/codec_dahdi.c Fri Jul 11 13:58:47 2008
@@ -466,7 +466,7 @@
static int unload_module(void)
{
- ast_cli_unregister_multiple(cli, sizeof(cli) / sizeof(cli[0]));
+ ast_cli_unregister_multiple(cli, ARRAY_LEN(cli));
unregister_translators();
return 0;
@@ -477,7 +477,7 @@
if (parse_config(0))
return AST_MODULE_LOAD_DECLINE;
find_transcoders();
- ast_cli_register_multiple(cli, sizeof(cli) / sizeof(cli[0]));
+ ast_cli_register_multiple(cli, ARRAY_LEN(cli));
return AST_MODULE_LOAD_SUCCESS;
}
Modified: team/tilghman/compiler_attributes/codecs/codec_g722.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/codecs/codec_g722.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/codecs/codec_g722.c (original)
+++ team/tilghman/compiler_attributes/codecs/codec_g722.c Fri Jul 11 13:58:47 2008
@@ -166,7 +166,7 @@
.frametype = AST_FRAME_VOICE,
.subclass = AST_FORMAT_SLINEAR,
.datalen = sizeof(slin_g722_ex),
- .samples = sizeof(slin_g722_ex) / sizeof(slin_g722_ex[0]),
+ .samples = ARRAY_LEN(slin_g722_ex),
.src = __PRETTY_FUNCTION__,
.data.ptr = slin_g722_ex,
};
@@ -180,7 +180,7 @@
.frametype = AST_FRAME_VOICE,
.subclass = AST_FORMAT_SLINEAR16,
.datalen = sizeof(slin_g722_ex),
- .samples = sizeof(slin_g722_ex) / sizeof(slin_g722_ex[0]),
+ .samples = ARRAY_LEN(slin_g722_ex),
.src = __PRETTY_FUNCTION__,
.data.ptr = slin_g722_ex,
};
Modified: team/tilghman/compiler_attributes/codecs/codec_resample.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/codecs/codec_resample.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/codecs/codec_resample.c (original)
+++ team/tilghman/compiler_attributes/codecs/codec_resample.c Fri Jul 11 13:58:47 2008
@@ -166,7 +166,7 @@
.frametype = AST_FRAME_VOICE,
.subclass = AST_FORMAT_SLINEAR16,
.datalen = sizeof(slin16_slin8_ex),
- .samples = sizeof(slin16_slin8_ex) / sizeof(slin16_slin8_ex[0]),
+ .samples = ARRAY_LEN(slin16_slin8_ex),
.src = __PRETTY_FUNCTION__,
.data.ptr = slin16_slin8_ex,
};
@@ -180,7 +180,7 @@
.frametype = AST_FRAME_VOICE,
.subclass = AST_FORMAT_SLINEAR,
.datalen = sizeof(slin8_slin16_ex),
- .samples = sizeof(slin8_slin16_ex) / sizeof(slin8_slin16_ex[0]),
+ .samples = ARRAY_LEN(slin8_slin16_ex),
.src = __PRETTY_FUNCTION__,
.data.ptr = slin8_slin16_ex,
};
Modified: team/tilghman/compiler_attributes/main/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/abstract_jb.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/main/abstract_jb.c (original)
+++ team/tilghman/compiler_attributes/main/abstract_jb.c Fri Jul 11 13:58:47 2008
@@ -176,7 +176,7 @@
struct ast_jb *jb = &chan->jb;
struct ast_jb_conf *jbconf = &jb->conf;
struct ast_jb_impl *test_impl;
- int i, avail_impl_count = sizeof(avail_impl) / sizeof(avail_impl[0]);
+ int i, avail_impl_count = ARRAY_LEN(avail_impl);
jb->impl = &avail_impl[default_impl];
Modified: team/tilghman/compiler_attributes/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/asterisk.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/main/asterisk.c (original)
+++ team/tilghman/compiler_attributes/main/asterisk.c Fri Jul 11 13:58:47 2008
@@ -2910,9 +2910,9 @@
char *remotesock = NULL;
/* Remember original args for restart */
- if (argc > sizeof(_argv) / sizeof(_argv[0]) - 1) {
- fprintf(stderr, "Truncating argument size to %d\n", (int)(sizeof(_argv) / sizeof(_argv[0])) - 1);
- argc = sizeof(_argv) / sizeof(_argv[0]) - 1;
+ if (argc > ARRAY_LEN(_argv) - 1) {
+ fprintf(stderr, "Truncating argument size to %d\n", (int)ARRAY_LEN(_argv) - 1);
+ argc = ARRAY_LEN(_argv) - 1;
}
for (x = 0; x < argc; x++)
_argv[x] = argv[x];
Modified: team/tilghman/compiler_attributes/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/cli.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/main/cli.c (original)
+++ team/tilghman/compiler_attributes/main/cli.c Fri Jul 11 13:58:47 2008
@@ -1777,7 +1777,7 @@
char matchstr[80] = "";
int tws = 0;
/* Split the argument into an array of words */
- char *dup = parse_args(text, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws);
+ char *dup = parse_args(text, &x, argv, ARRAY_LEN(argv), &tws);
if (!dup) /* malloc error */
return NULL;
Modified: team/tilghman/compiler_attributes/main/dsp.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/dsp.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/main/dsp.c (original)
+++ team/tilghman/compiler_attributes/main/dsp.c Fri Jul 11 13:58:47 2008
@@ -393,7 +393,7 @@
static void mute_fragment(struct ast_dsp *dsp, fragment_t *fragment)
{
- if (dsp->mute_fragments >= sizeof(dsp->mute_data) / sizeof(dsp->mute_data[0])) {
+ if (dsp->mute_fragments >= ARRAY_LEN(dsp->mute_data)) {
ast_log(LOG_ERROR, "Too many fragments to mute. Ignoring\n");
return;
}
@@ -1440,7 +1440,7 @@
dsp->gsamp_size = modes[dsp->progmode].size;
dsp->gsamps = 0;
- for (x = 0; x < sizeof(modes[dsp->progmode].freqs) / sizeof(modes[dsp->progmode].freqs[0]); x++) {
+ for (x = 0; x < ARRAY_LEN(modes[dsp->progmode].freqs); x++) {
if (modes[dsp->progmode].freqs[x]) {
goertzel_init(&dsp->freqs[x], (float)modes[dsp->progmode].freqs[x], dsp->gsamp_size);
max = x + 1;
Modified: team/tilghman/compiler_attributes/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/compiler_attributes/main/pbx.c?view=diff&rev=130172&r1=130171&r2=130172
==============================================================================
--- team/tilghman/compiler_attributes/main/pbx.c (original)
+++ team/tilghman/compiler_attributes/main/pbx.c Fri Jul 11 13:58:47 2008
@@ -354,8 +354,10 @@
const struct ast_exten *ac = ah_a;
const struct ast_exten *bc = ah_b;
int x = strcmp(ac->exten, bc->exten);
- if (x) /* if exten names are diff, then return */
+ if (x) { /* if exten names are diff, then return */
return x;
+ }
+
/* but if they are the same, do the cidmatch values match? */
if (ac->matchcid && bc->matchcid) {
return strcmp(ac->cidmatch,bc->cidmatch);
@@ -727,6 +729,185 @@
static AST_RWLIST_HEAD_STATIC(hints, ast_hint);
static AST_LIST_HEAD_NOLOCK_STATIC(statecbs, ast_state_cb);
+
+#ifdef CONTEXT_DEBUG
+
+/* these routines are provided for doing run-time checks
+ on the extension structures, in case you are having
+ problems, this routine might help you localize where
+ the problem is occurring. It's kinda like a debug memory
+ allocator's arena checker... It'll eat up your cpu cycles!
+ but you'll see, if you call it in the right places,
+ right where your problems began...
+*/
+
+/* you can break on the check_contexts_trouble()
+routine in your debugger to stop at the moment
+there's a problem */
+void check_contexts_trouble(void);
+
+void check_contexts_trouble(void)
+{
+ int x = 1;
+ x = 2;
+}
+
+static struct ast_context *find_context_locked(const char *context);
+int check_contexts(char *, int);
+
+int check_contexts(char *file, int line )
+{
+ struct ast_hashtab_iter *t1;
+ struct ast_context *c1, *c2;
+ int found = 0;
+ struct ast_exten *e1, *e2, *e3;
+ struct ast_exten ex;
+
+ /* try to find inconsistencies */
+ /* is every context in the context table in the context list and vice-versa ? */
+
+ if (!contexts_table) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: No contexts_table!\n", file, line);
+ usleep(500000);
+ }
+
+ t1 = ast_hashtab_start_traversal(contexts_table);
+ while( (c1 = ast_hashtab_next(t1))) {
+ for(c2=contexts;c2;c2=c2->next) {
+ if (!strcmp(c1->name, c2->name)) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: Could not find the %s context in the linked list\n", file, line, c1->name);
+ check_contexts_trouble();
+ }
+ }
+ ast_hashtab_end_traversal(t1);
+ for(c2=contexts;c2;c2=c2->next) {
+ c1 = find_context_locked(c2->name);
+ if (!c1) {
+ ast_log(LOG_NOTICE,"Could not find the %s context in the hashtab\n", c2->name);
+ check_contexts_trouble();
+ } else
+ ast_unlock_contexts();
+ }
+
+ /* loop thru all contexts, and verify the exten structure compares to the
+ hashtab structure */
+ for(c2=contexts;c2;c2=c2->next) {
+ c1 = find_context_locked(c2->name);
+ if (c1)
+ {
+
+ ast_unlock_contexts();
+
+ /* is every entry in the root list also in the root_table? */
+ for(e1 = c1->root; e1; e1=e1->next)
+ {
+ char dummy_name[1024];
+ ex.exten = dummy_name;
+ ex.matchcid = e1->matchcid;
+ ex.cidmatch = e1->cidmatch;
+ ast_copy_string(dummy_name, e1->exten, sizeof(dummy_name));
+ e2 = ast_hashtab_lookup(c1->root_table, &ex);
+ if (!e2) {
+ if (e1->matchcid) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context records the exten %s (CID match: %s) but it is not in its root_table\n", file, line, c2->name, dummy_name, e1->cidmatch );
+ } else {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context records the exten %s but it is not in its root_table\n", file, line, c2->name, dummy_name );
+ }
+ check_contexts_trouble();
+ }
+ }
+
+ /* is every entry in the root_table also in the root list? */
+ if (!c2->root_table) {
+ if (c2->root) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: No c2->root_table for context %s!\n", file, line, c2->name);
+ usleep(500000);
+ }
+ } else {
+ t1 = ast_hashtab_start_traversal(c2->root_table);
+ while( (e2 = ast_hashtab_next(t1)) ) {
+ for(e1=c2->root;e1;e1=e1->next) {
+ if (!strcmp(e1->exten, e2->exten)) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context records the exten %s but it is not in its root_table\n", file, line, c2->name, e2->exten);
+ check_contexts_trouble();
+ }
+
+ }
+ ast_hashtab_end_traversal(t1);
+ }
+ }
+ /* is every priority reflected in the peer_table at the head of the list? */
+
+ /* is every entry in the root list also in the root_table? */
+ /* are the per-extension peer_tables in the right place? */
+
+ for(e1 = c2->root; e1; e1 = e1->next) {
+
+ for(e2=e1;e2;e2=e2->peer) {
+ ex.priority = e2->priority;
+ if (e2 != e1 && e2->peer_table) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority has a peer_table entry, and shouldn't!\n", file, line, c2->name, e1->exten, e2->priority );
+ check_contexts_trouble();
+ }
+
+ if (e2 != e1 && e2->peer_label_table) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority has a peer_label_table entry, and shouldn't!\n", file, line, c2->name, e1->exten, e2->priority );
+ check_contexts_trouble();
+ }
+
+ if (e2 == e1 && !e2->peer_table){
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority doesn't have a peer_table!\n", file, line, c2->name, e1->exten, e2->priority );
+ check_contexts_trouble();
+ }
+
+ if (e2 == e1 && !e2->peer_label_table) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority doesn't have a peer_label_table!\n", file, line, c2->name, e1->exten, e2->priority );
+ check_contexts_trouble();
+ }
+
+
+ e3 = ast_hashtab_lookup(e1->peer_table, &ex);
+ if (!e3) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority is not reflected in the peer_table\n", file, line, c2->name, e1->exten, e2->priority );
+ check_contexts_trouble();
+ }
+ }
+
+ if (!e1->peer_table){
+ ast_log(LOG_NOTICE,"Called from: %s:%d: No e1->peer_table!\n", file, line);
+ usleep(500000);
+ }
+
+ /* is every entry in the peer_table also in the peer list? */
+ t1 = ast_hashtab_start_traversal(e1->peer_table);
+ while( (e2 = ast_hashtab_next(t1)) ) {
+ for(e3=e1;e3;e3=e3->peer) {
+ if (e3->priority == e2->priority) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ ast_log(LOG_NOTICE,"Called from: %s:%d: The %s context, %s exten, %d priority is not reflected in the peer list\n", file, line, c2->name, e1->exten, e2->priority );
+ check_contexts_trouble();
+ }
+ }
+ ast_hashtab_end_traversal(t1);
+ }
+ }
+ return 0;
+}
+#endif
/*
\note This function is special. It saves the stack so that no matter
@@ -4060,15 +4241,17 @@
#ifdef NEED_DEBUG
ast_verb(3,"Removing %s/%s/%d%s%s from trees, registrar=%s\n", con->name, extension, priority, matchcid ? "/" : "", matchcid ? callerid : "", registrar);
#endif
+#ifdef CONTEXT_DEBUG
+ check_contexts(__FILE__, __LINE__);
+#endif
/* find this particular extension */
ex.exten = dummy_name;
- ex.matchcid = matchcid;
+ ex.matchcid = matchcid && !ast_strlen_zero(callerid); /* don't say match if there's no callerid */
ex.cidmatch = callerid;
ast_copy_string(dummy_name, extension, sizeof(dummy_name));
exten = ast_hashtab_lookup(con->root_table, &ex);
if (exten) {
- if (priority == 0)
- {
+ if (priority == 0) {
exten2 = ast_hashtab_remove_this_object(con->root_table, exten);
if (!exten2)
ast_log(LOG_ERROR,"Trying to delete the exten %s from context %s, but could not remove from the root_table\n", extension, con->name);
@@ -4135,7 +4318,8 @@
/* scan the extension list to find first matching extension-registrar */
for (exten = con->root; exten; prev_exten = exten, exten = exten->next) {
if (!strcmp(exten->exten, extension) &&
- (!registrar || !strcmp(exten->registrar, registrar)))
+ (!registrar || !strcmp(exten->registrar, registrar)) &&
+ (!matchcid || (!ast_strlen_zero(callerid) && !ast_strlen_zero(exten->cidmatch) && !strcmp(exten->cidmatch, callerid)) || (ast_strlen_zero(callerid) && ast_strlen_zero(exten->cidmatch))))
break;
}
if (!exten) {
@@ -4147,7 +4331,7 @@
/* scan the priority list to remove extension with exten->priority == priority */
for (peer = exten, next_peer = exten->peer ? exten->peer : exten->next;
- peer && !strcmp(peer->exten, extension);
+ peer && !strcmp(peer->exten, extension) && (!matchcid || (!ast_strlen_zero(callerid) && !ast_strlen_zero(peer->cidmatch) && !strcmp(peer->cidmatch,callerid)) || (ast_strlen_zero(callerid) && ast_strlen_zero(peer->cidmatch)));
peer = next_peer, next_peer = next_peer ? (next_peer->peer ? next_peer->peer : next_peer->next) : NULL) {
if ((priority == 0 || peer->priority == priority) &&
(!callerid || !matchcid || (matchcid && !strcmp(peer->cidmatch, callerid))) &&
@@ -4161,7 +4345,14 @@
* The next node is either the next priority or the next extension
*/
struct ast_exten *next_node = peer->peer ? peer->peer : peer->next;
-
+ if (peer->peer) {
+ /* move the peer_table and peer_label_table down to the next peer, if
+ it is there */
+ peer->peer->peer_table = peer->peer_table;
+ peer->peer->peer_label_table = peer->peer_label_table;
+ peer->peer_table = NULL;
+ peer->peer_label_table = NULL;
+ }
if (!prev_exten) { /* change the root... */
con->root = next_node;
} else {
@@ -4180,6 +4371,9 @@
previous_peer = peer;
}
}
+#ifdef CONTEXT_DEBUG
+ check_contexts(__FILE__, __LINE__);
+#endif
if (!already_locked)
ast_unlock_context(con);
return found ? 0 : -1;
@@ -6361,8 +6555,10 @@
}
if (!e) { /* go at the end, and ep is surely set because the list is not empty */
ast_hashtab_insert_safe(eh->peer_table, tmp);
- if (tmp->label)
+
+ if (tmp->label) {
ast_hashtab_insert_safe(eh->peer_label_table, tmp);
+ }
ep->peer = tmp;
return 0; /* success */
}
@@ -6383,11 +6579,16 @@
tmp->peer = e->peer; /* always meaningful */
if (ep) { /* We're in the peer list, just insert ourselves */
ast_hashtab_remove_object_via_lookup(eh->peer_table,e);
- if (e->label)
+
+ if (e->label) {
ast_hashtab_remove_object_via_lookup(eh->peer_label_table,e);
+ }
+
ast_hashtab_insert_safe(eh->peer_table,tmp);
- if (tmp->label)
+ if (tmp->label) {
ast_hashtab_insert_safe(eh->peer_label_table,tmp);
+ }
+
ep->peer = tmp;
} else if (el) { /* We're the first extension. Take over e's functions */
struct match_char *x = add_exten_to_pattern_tree(con, e, 1);
@@ -6395,10 +6596,13 @@
tmp->peer_label_table = e->peer_label_table;
ast_hashtab_remove_object_via_lookup(tmp->peer_table,e);
ast_hashtab_insert_safe(tmp->peer_table,tmp);
- if (e->label)
+ if (e->label) {
ast_hashtab_remove_object_via_lookup(tmp->peer_label_table, e);
- if (tmp->label)
+ }
+ if (tmp->label) {
ast_hashtab_insert_safe(tmp->peer_label_table, tmp);
+ }
+
ast_hashtab_remove_object_via_lookup(con->root_table, e);
[... 246 lines stripped ...]
More information about the asterisk-commits
mailing list