[asterisk-commits] murf: branch group/CDRfix5 r74510 - in /team/group/CDRfix5: apps/ channels/ f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 10 20:51:08 CDT 2007
Author: murf
Date: Tue Jul 10 20:51:07 2007
New Revision: 74510
URL: http://svn.digium.com/view/asterisk?view=rev&rev=74510
Log:
Completely eradicated the next pointer from the CDR structure. Got rid of every call to ast_cdr_append. We are now in a state where the CDR field on a channel holds a prototype for bridged calls. No more CDRs will be generated for unanswered/busy/failed calls.
Modified:
team/group/CDRfix5/apps/app_meetme.c
team/group/CDRfix5/channels/chan_sip.c
team/group/CDRfix5/channels/chan_zap.c
team/group/CDRfix5/funcs/func_cdr.c
team/group/CDRfix5/include/asterisk/cdr.h
team/group/CDRfix5/main/cdr.c
team/group/CDRfix5/res/res_features.c
Modified: team/group/CDRfix5/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/group/CDRfix5/apps/app_meetme.c?view=diff&rev=74510&r1=74509&r2=74510
==============================================================================
--- team/group/CDRfix5/apps/app_meetme.c (original)
+++ team/group/CDRfix5/apps/app_meetme.c Tue Jul 10 20:51:07 2007
@@ -2328,12 +2328,6 @@
ast_cdr_log("Closing CDR attached to CHAN", chan->cdr);
if (chan->masqr && chan->masqr->cdr)
ast_cdr_log("Closing CDR attached to Masqueraded CHAN", chan->masqr->cdr);
- if (chan->masqr && chan->masqr->cdr && chan->masqr->cdr->next)
- ast_cdr_log("Closing NEXT CDR attached to Masqueraded CHAN", chan->masqr->cdr->next);
- if (chan->masqr && chan->masqr->cdr && chan->masqr->cdr->next && chan->masqr->cdr->next->next)
- ast_cdr_log("Closing NEXT NEXT CDR attached to Masqueraded CHAN", chan->masqr->cdr->next->next);
- if (chan->masqr && chan->masqr->cdr && chan->masqr->cdr->next && chan->masqr->cdr->next->next && chan->masqr->cdr->next->next->next)
- ast_cdr_log("Closing NEXT NEXT NEXT CDR attached to Masqueraded CHAN", chan->masqr->cdr->next->next->next);
ast_cdr_detach(bridge_cdr);
Modified: team/group/CDRfix5/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/CDRfix5/channels/chan_sip.c?view=diff&rev=74510&r1=74509&r2=74510
==============================================================================
--- team/group/CDRfix5/channels/chan_sip.c (original)
+++ team/group/CDRfix5/channels/chan_sip.c Tue Jul 10 20:51:07 2007
@@ -13700,17 +13700,15 @@
ast_quiet_chan(peerd);
/* Fix CDRs so they're attached to the remaining channel */
- if (peera->cdr && peerb->cdr)
- peerb->cdr = ast_cdr_append(peerb->cdr, peera->cdr);
- else if (peera->cdr)
+ if (peera->cdr && !peerb->cdr) {
peerb->cdr = peera->cdr;
- peera->cdr = NULL;
-
- if (peerb->cdr && peerc->cdr)
- peerb->cdr = ast_cdr_append(peerb->cdr, peerc->cdr);
- else if (peerc->cdr)
+ peera->cdr = NULL;
+ }
+
+ if (peerc->cdr && !peerb->cdr) {
peerb->cdr = peerc->cdr;
- peerc->cdr = NULL;
+ peerc->cdr = NULL;
+ }
ast_debug(4, "SIP transfer: trying to masquerade %s into %s\n", peerc->name, peerb->name);
if (ast_channel_masquerade(peerb, peerc)) {
Modified: team/group/CDRfix5/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/group/CDRfix5/channels/chan_zap.c?view=diff&rev=74510&r1=74509&r2=74510
==============================================================================
--- team/group/CDRfix5/channels/chan_zap.c (original)
+++ team/group/CDRfix5/channels/chan_zap.c Tue Jul 10 20:51:07 2007
@@ -3781,18 +3781,6 @@
if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RING) {
tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, ZT_TONE_RINGTONE);
}
- if (p->subs[SUB_REAL].owner->cdr) {
- /* Move CDR from second channel to current one */
- p->subs[SUB_THREEWAY].owner->cdr =
- ast_cdr_append(p->subs[SUB_THREEWAY].owner->cdr, p->subs[SUB_REAL].owner->cdr);
- p->subs[SUB_REAL].owner->cdr = NULL;
- }
- if (ast_bridged_channel(p->subs[SUB_REAL].owner)->cdr) {
- /* Move CDR from second channel's bridge to current one */
- p->subs[SUB_THREEWAY].owner->cdr =
- ast_cdr_append(p->subs[SUB_THREEWAY].owner->cdr, ast_bridged_channel(p->subs[SUB_REAL].owner)->cdr);
- ast_bridged_channel(p->subs[SUB_REAL].owner)->cdr = NULL;
- }
if (ast_channel_masquerade(p->subs[SUB_THREEWAY].owner, ast_bridged_channel(p->subs[SUB_REAL].owner))) {
ast_log(LOG_WARNING, "Unable to masquerade %s as %s\n",
ast_bridged_channel(p->subs[SUB_REAL].owner)->name, p->subs[SUB_THREEWAY].owner->name);
@@ -3808,18 +3796,6 @@
}
if (p->subs[SUB_REAL].owner->_state == AST_STATE_RING) {
tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE);
- }
- if (p->subs[SUB_THREEWAY].owner->cdr) {
- /* Move CDR from second channel to current one */
- p->subs[SUB_REAL].owner->cdr =
- ast_cdr_append(p->subs[SUB_REAL].owner->cdr, p->subs[SUB_THREEWAY].owner->cdr);
- p->subs[SUB_THREEWAY].owner->cdr = NULL;
- }
- if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)->cdr) {
- /* Move CDR from second channel's bridge to current one */
- p->subs[SUB_REAL].owner->cdr =
- ast_cdr_append(p->subs[SUB_REAL].owner->cdr, ast_bridged_channel(p->subs[SUB_THREEWAY].owner)->cdr);
- ast_bridged_channel(p->subs[SUB_THREEWAY].owner)->cdr = NULL;
}
if (ast_channel_masquerade(p->subs[SUB_REAL].owner, ast_bridged_channel(p->subs[SUB_THREEWAY].owner))) {
ast_log(LOG_WARNING, "Unable to masquerade %s as %s\n",
Modified: team/group/CDRfix5/funcs/func_cdr.c
URL: http://svn.digium.com/view/asterisk/team/group/CDRfix5/funcs/func_cdr.c?view=diff&rev=74510&r1=74509&r2=74510
==============================================================================
--- team/group/CDRfix5/funcs/func_cdr.c (original)
+++ team/group/CDRfix5/funcs/func_cdr.c Tue Jul 10 20:51:07 2007
@@ -49,7 +49,6 @@
} cdr_option_flags;
AST_APP_OPTIONS(cdr_func_options, {
- AST_APP_OPTION('l', OPT_LAST),
AST_APP_OPTION('r', OPT_RECURSIVE),
AST_APP_OPTION('u', OPT_UNPARSED),
});
@@ -76,10 +75,6 @@
if (!ast_strlen_zero(args.options))
ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
-
- if (ast_test_flag(&flags, OPT_LAST))
- while (cdr->next)
- cdr = cdr->next;
ast_cdr_getvar(cdr, args.variable, &ret, buf, len,
ast_test_flag(&flags, OPT_RECURSIVE),
Modified: team/group/CDRfix5/include/asterisk/cdr.h
URL: http://svn.digium.com/view/asterisk/team/group/CDRfix5/include/asterisk/cdr.h?view=diff&rev=74510&r1=74509&r2=74510
==============================================================================
--- team/group/CDRfix5/include/asterisk/cdr.h (original)
+++ team/group/CDRfix5/include/asterisk/cdr.h Tue Jul 10 20:51:07 2007
@@ -95,7 +95,7 @@
/* A linked list for variables */
struct varshead varshead;
- struct ast_cdr *next;
+ /* no more cdr stack struct ast_cdr *next; */
};
void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur, int raw);
@@ -316,8 +316,6 @@
extern char ast_default_accountcode[AST_MAX_ACCOUNT_CODE];
-struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr);
-
/*! Reload the configuration file cdr.conf and start/stop CDR scheduling thread */
int ast_cdr_engine_reload(void);
Modified: team/group/CDRfix5/main/cdr.c
URL: http://svn.digium.com/view/asterisk/team/group/CDRfix5/main/cdr.c?view=diff&rev=74510&r1=74509&r2=74510
==============================================================================
--- team/group/CDRfix5/main/cdr.c (original)
+++ team/group/CDRfix5/main/cdr.c Tue Jul 10 20:51:07 2007
@@ -179,7 +179,6 @@
/* The varshead is unusable, volatile even, after the memcpy so we take care of that here */
memset(&newcdr->varshead, 0, sizeof(newcdr->varshead));
ast_cdr_copy_vars(newcdr, cdr);
- newcdr->next = NULL;
return newcdr;
}
@@ -450,220 +449,6 @@
return x;
}
-static void cdr_merge_vars(struct ast_cdr *to, struct ast_cdr *from)
-{
- struct ast_var_t *variablesfrom,*variablesto;
- struct varshead *headpfrom = &to->varshead;
- struct varshead *headpto = &from->varshead;
- AST_LIST_TRAVERSE_SAFE_BEGIN(headpfrom, variablesfrom, entries) {
- /* for every var in from, stick it in to */
- const char *fromvarname, *fromvarval;
- const char *tovarname = NULL, *tovarval = NULL;
- fromvarname = ast_var_name(variablesfrom);
- fromvarval = ast_var_value(variablesfrom);
- tovarname = 0;
-
- /* now, quick see if that var is in the 'to' cdr already */
- AST_LIST_TRAVERSE(headpto, variablesto, entries) {
-
- /* now, quick see if that var is in the 'to' cdr already */
- if ( strcasecmp(fromvarname, ast_var_name(variablesto)) == 0 ) {
- tovarname = ast_var_name(variablesto);
- tovarval = ast_var_value(variablesto);
- break;
- }
- }
- if (tovarname && strcasecmp(fromvarval,tovarval) != 0) { /* this message here to see how irritating the userbase finds it */
- ast_log(LOG_NOTICE, "Merging CDR's: variable %s value %s dropped in favor of value %s\n", tovarname, fromvarval, tovarval);
- continue;
- } else if (tovarname && strcasecmp(fromvarval,tovarval) == 0) /* if they are the same, the job is done */
- continue;
-
- /*rip this var out of the from cdr, and stick it in the to cdr */
- AST_LIST_REMOVE_CURRENT(headpfrom, entries);
- AST_LIST_INSERT_HEAD(headpto, variablesfrom, entries);
- }
- AST_LIST_TRAVERSE_SAFE_END;
-}
-
-void ast_cdr_merge(struct ast_cdr *to, struct ast_cdr *from)
-{
- struct ast_cdr *zcdr;
- struct ast_cdr *lto = NULL;
- struct ast_cdr *lfrom = NULL;
- int discard_from = 0;
-
- if (!to || !from)
- return;
-
- /* don't merge into locked CDR's -- it's bad business */
- if (ast_test_flag(to, AST_CDR_FLAG_LOCKED)) {
- zcdr = to; /* safety valve? */
- while (to->next) {
- lto = to;
- to = to->next;
- }
-
- if (ast_test_flag(to, AST_CDR_FLAG_LOCKED)) {
- ast_log(LOG_WARNING, "Merging into locked CDR... no choice.");
- to = zcdr; /* safety-- if all there are is locked CDR's, then.... ?? */
- lto = NULL;
- }
- }
-
- if (ast_test_flag(from, AST_CDR_FLAG_LOCKED)) {
- struct ast_cdr *llfrom = NULL;
- discard_from = 1;
- if (lto) {
- /* insert the from stuff after lto */
- lto->next = from;
- lfrom = from;
- while (lfrom && lfrom->next) {
- if (!lfrom->next->next)
- llfrom = lfrom;
- lfrom = lfrom->next;
- }
- /* rip off the last entry and put a copy of the to at the end */
- llfrom->next = to;
- from = lfrom;
- } else {
- /* save copy of the current *to cdr */
- struct ast_cdr tcdr;
- memcpy(&tcdr, to, sizeof(tcdr));
- /* copy in the locked from cdr */
- memcpy(to, from, sizeof(*to));
- lfrom = from;
- while (lfrom && lfrom->next) {
- if (!lfrom->next->next)
- llfrom = lfrom;
- lfrom = lfrom->next;
- }
- from->next = NULL;
- /* rip off the last entry and put a copy of the to at the end */
- if (llfrom == from)
- to = to->next = ast_cdr_dup(&tcdr);
- else
- to = llfrom->next = ast_cdr_dup(&tcdr);
- from = lfrom;
- }
- }
-
- if (!ast_tvzero(from->start)) {
- if (!ast_tvzero(to->start)) {
- if (ast_tvcmp(to->start, from->start) > 0 ) {
- to->start = from->start; /* use the earliest time */
- from->start = ast_tv(0,0); /* we actively "steal" these values */
- }
- /* else nothing to do */
- } else {
- to->start = from->start;
- from->start = ast_tv(0,0); /* we actively "steal" these values */
- }
- }
- if (!ast_tvzero(from->answer)) {
- if (!ast_tvzero(to->answer)) {
- if (ast_tvcmp(to->answer, from->answer) > 0 ) {
- to->answer = from->answer; /* use the earliest time */
- from->answer = ast_tv(0,0); /* we actively "steal" these values */
- }
- /* we got the earliest answer time, so we'll settle for that? */
- } else {
- to->answer = from->answer;
- from->answer = ast_tv(0,0); /* we actively "steal" these values */
- }
- }
- if (!ast_tvzero(from->end)) {
- if (!ast_tvzero(to->end)) {
- if (ast_tvcmp(to->end, from->end) < 0 ) {
- to->end = from->end; /* use the latest time */
- from->end = ast_tv(0,0); /* we actively "steal" these values */
- to->duration = to->end.tv_sec - to->start.tv_sec; /* don't forget to update the duration, billsec, when we set end */
- to->billsec = ast_tvzero(to->answer) ? 0 : to->end.tv_sec - to->answer.tv_sec;
- }
- /* else, nothing to do */
- } else {
- to->end = from->end;
- from->end = ast_tv(0,0); /* we actively "steal" these values */
- to->duration = to->end.tv_sec - to->start.tv_sec;
- to->billsec = ast_tvzero(to->answer) ? 0 : to->end.tv_sec - to->answer.tv_sec;
- }
- }
- if (to->disposition < from->disposition) {
- to->disposition = from->disposition;
- from->disposition = AST_CDR_NOANSWER;
- }
- if (ast_strlen_zero(to->lastapp) && !ast_strlen_zero(from->lastapp)) {
- ast_copy_string(to->lastapp, from->lastapp, sizeof(to->lastapp));
- from->lastapp[0] = 0; /* theft */
- }
- if (ast_strlen_zero(to->lastdata) && !ast_strlen_zero(from->lastdata)) {
- ast_copy_string(to->lastdata, from->lastdata, sizeof(to->lastdata));
- from->lastdata[0] = 0; /* theft */
- }
- if (ast_strlen_zero(to->dcontext) && !ast_strlen_zero(from->dcontext)) {
- ast_copy_string(to->dcontext, from->dcontext, sizeof(to->dcontext));
- from->dcontext[0] = 0; /* theft */
- }
- if (ast_strlen_zero(to->dstchannel) && !ast_strlen_zero(from->dstchannel)) {
- ast_copy_string(to->dstchannel, from->dstchannel, sizeof(to->dstchannel));
- from->dstchannel[0] = 0; /* theft */
- }
- if (!ast_strlen_zero(from->channel) && (ast_strlen_zero(to->channel) || !strncasecmp(from->channel, "Agent/", 6))) {
- ast_copy_string(to->channel, from->channel, sizeof(to->channel));
- from->channel[0] = 0; /* theft */
- }
- if (ast_strlen_zero(to->src) && !ast_strlen_zero(from->src)) {
- ast_copy_string(to->src, from->src, sizeof(to->src));
- from->src[0] = 0; /* theft */
- }
- if (ast_strlen_zero(to->clid) && !ast_strlen_zero(from->clid)) {
- ast_copy_string(to->clid, from->clid, sizeof(to->clid));
- from->clid[0] = 0; /* theft */
- }
- if (ast_strlen_zero(to->dst) && !ast_strlen_zero(from->dst)) {
- ast_copy_string(to->dst, from->dst, sizeof(to->dst));
- from->dst[0] = 0; /* theft */
- }
- if (!to->amaflags)
- to->amaflags = AST_CDR_DOCUMENTATION;
- if (!from->amaflags)
- from->amaflags = AST_CDR_DOCUMENTATION; /* make sure both amaflags are set to something (DOC is default) */
- if (ast_test_flag(from, AST_CDR_FLAG_LOCKED) || (to->amaflags == AST_CDR_DOCUMENTATION && from->amaflags != AST_CDR_DOCUMENTATION)) {
- to->amaflags = from->amaflags;
- }
- if (ast_test_flag(from, AST_CDR_FLAG_LOCKED) || (ast_strlen_zero(to->accountcode) && !ast_strlen_zero(from->accountcode))) {
- ast_copy_string(to->accountcode, from->accountcode, sizeof(to->accountcode));
- }
- if (ast_test_flag(from, AST_CDR_FLAG_LOCKED) || (ast_strlen_zero(to->userfield) && !ast_strlen_zero(from->userfield))) {
- ast_copy_string(to->userfield, from->userfield, sizeof(to->userfield));
- }
- /* flags, varsead, ? */
- cdr_merge_vars(from, to);
-
- if (ast_test_flag(from, AST_CDR_FLAG_KEEP_VARS))
- ast_set_flag(to, AST_CDR_FLAG_KEEP_VARS);
- if (ast_test_flag(from, AST_CDR_FLAG_POSTED))
- ast_set_flag(to, AST_CDR_FLAG_POSTED);
- if (ast_test_flag(from, AST_CDR_FLAG_LOCKED))
- ast_set_flag(to, AST_CDR_FLAG_LOCKED);
- if (ast_test_flag(from, AST_CDR_FLAG_CHILD))
- ast_set_flag(to, AST_CDR_FLAG_CHILD);
- if (ast_test_flag(from, AST_CDR_FLAG_POST_DISABLED))
- ast_set_flag(to, AST_CDR_FLAG_POST_DISABLED);
-
- /* last, but not least, we need to merge any forked CDRs to the 'to' cdr */
- while (from->next) {
- /* just rip 'em off the 'from' and insert them on the 'to' */
- zcdr = from->next;
- from->next = zcdr->next;
- zcdr->next = NULL;
- /* zcdr is now ripped from the current list; */
- ast_cdr_append(to, zcdr);
- }
- if (discard_from)
- ast_cdr_discard(from);
-}
-
void ast_cdr_start(struct ast_cdr *cdr)
{
char *chan;
@@ -1008,23 +793,6 @@
}
-struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr)
-{
- struct ast_cdr *ret;
-
- if (cdr) {
- ret = cdr;
-
- while (cdr->next)
- cdr = cdr->next;
- cdr->next = newcdr;
- } else {
- ret = newcdr;
- }
-
- return ret;
-}
-
/*! \note Don't call without cdr_batch_lock */
static void reset_batch(void)
{
Modified: team/group/CDRfix5/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/group/CDRfix5/res/res_features.c?view=diff&rev=74510&r1=74509&r2=74510
==============================================================================
--- team/group/CDRfix5/res/res_features.c (original)
+++ team/group/CDRfix5/res/res_features.c Tue Jul 10 20:51:07 2007
@@ -1589,10 +1589,10 @@
cdr->duration, cdr->billsec, cdr->disposition, cdr->amaflags);
ast_log(LOG_NOTICE, "CDR: acctcode: %s; flags: %x; uniqueid: %s; userfield: %s; linkedID:%s\n",
cdr->accountcode, cdr->flags, cdr->uniqueid, cdr->userfield, cdr->linkedid);
- ast_log(LOG_NOTICE, "CDR: next: %x;\n",
- (unsigned int)cdr->next);
ast_log(LOG_NOTICE, "===== done ====\n");
}
+
+
void ast_channel_log(char *title, struct ast_channel *chan);
@@ -1905,12 +1905,6 @@
ast_cdr_log("Closing CDR attached to PEER", peer->cdr);
if (chan->masqr && chan->masqr->cdr)
ast_cdr_log("Closing CDR attached to Masqueraded CHAN", chan->masqr->cdr);
- if (chan->masqr && chan->masqr->cdr && chan->masqr->cdr->next)
- ast_cdr_log("Closing NEXT CDR attached to Masqueraded CHAN", chan->masqr->cdr->next);
- if (chan->masqr && chan->masqr->cdr && chan->masqr->cdr->next && chan->masqr->cdr->next->next)
- ast_cdr_log("Closing NEXT NEXT CDR attached to Masqueraded CHAN", chan->masqr->cdr->next->next);
- if (chan->masqr && chan->masqr->cdr && chan->masqr->cdr->next && chan->masqr->cdr->next->next && chan->masqr->cdr->next->next->next)
- ast_cdr_log("Closing NEXT NEXT NEXT CDR attached to Masqueraded CHAN", chan->masqr->cdr->next->next->next);
ast_cdr_detach(bridge_cdr);
More information about the asterisk-commits
mailing list