diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-29 04:11:53 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-29 04:11:53 +0000 |
commit | c16d6c9c1b2ddb789f7a65854f6c212197a9b5ef (patch) | |
tree | 192db2b19d322008a70a266fd4bbff723e66febd /main | |
parent | d63ce6eba05e5d5bd51566ae3a2b725c2c504484 (diff) |
Merged revisions 118880 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r118880 | murf | 2008-05-28 19:29:09 -0600 (Wed, 28 May 2008) | 54 lines
Merged revisions 118858 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r118858 | murf | 2008-05-28 18:25:28 -0600 (Wed, 28 May 2008) | 46 lines
(closes issue #10668)
(closes issue #11721)
(closes issue #12726)
Reported by: arkadia
Tested by: murf
These changes:
1. revert the changes made via bug 10668;
I should have known that such changes,
even tho they made sense at the time,
seemed like an omission, etc, were actually
integral to the CDR system via forkCDR.
It makes sense to me now that forkCDR didn't
natively end any CDR's, but rather depended
on natively closing them all at hangup time
via traversing and closing them all, whether
locked or not. I still don't completely
understand the benefits of setvar and answer
operating on locked cdrs, but I've seen
enough to revert those changes also, and
stop messing up users who depended on that
behavior. bug 12726 found reverting the changes
fixed his changes, and after a long review
and working on forkCDR, I can see why.
2. Apply the suggested enhancements proposed
in 10668, but in a completely compatible
way. ForkCDR will behave exactly as before,
but now has new options that will allow some
actions to be taken that will slightly
modify the outcome and side-effects of
forkCDR. Based on conversations I've had
with various people, these small tweaks
will allow some users to get the behavior
they need. For instance, users executing
forkCDR in an AGI script will find the
answer time set, and DISPOSITION set,
a situation not covered when the routines
were first written.
3. A small problem in the cdr serializer
would output answer and end times even
when they were not set. This is now
fixed.
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@118909 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/cdr.c | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/main/cdr.c b/main/cdr.c index 5b68e8fed..ee6819aae 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -306,23 +306,21 @@ int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int } for (; cdr; cdr = recur ? cdr->next : NULL) { - if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { - headp = &cdr->varshead; - AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) { - if (!strcasecmp(ast_var_name(newvariable), name)) { - /* there is already such a variable, delete it */ - AST_LIST_REMOVE_CURRENT(entries); - ast_var_delete(newvariable); - break; - } - } - AST_LIST_TRAVERSE_SAFE_END; - - if (value) { - newvariable = ast_var_assign(name, value); - AST_LIST_INSERT_HEAD(headp, newvariable, entries); + headp = &cdr->varshead; + AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) { + if (!strcasecmp(ast_var_name(newvariable), name)) { + /* there is already such a variable, delete it */ + AST_LIST_REMOVE_CURRENT(entries); + ast_var_delete(newvariable); + break; } } + AST_LIST_TRAVERSE_SAFE_END; + + if (value) { + newvariable = ast_var_assign(name, value); + AST_LIST_INSERT_HEAD(headp, newvariable, entries); + } } return 0; @@ -383,6 +381,7 @@ int ast_cdr_serialize_variables(struct ast_cdr *cdr, struct ast_str **buf, char } for (i = 0; cdr_readonly_vars[i]; i++) { + workspace[0] = 0; /* null out the workspace, because the cdr_get_tv() won't write anything if time is NULL, so you get old vals */ ast_cdr_getvar(cdr, cdr_readonly_vars[i], &tmp, workspace, sizeof(workspace), 0, 0); if (!tmp) continue; @@ -690,13 +689,11 @@ void ast_cdr_answer(struct ast_cdr *cdr) { for (; cdr; cdr = cdr->next) { - if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { - check_post(cdr); - if (cdr->disposition < AST_CDR_ANSWERED) - cdr->disposition = AST_CDR_ANSWERED; - if (ast_tvzero(cdr->answer)) - cdr->answer = ast_tvnow(); - } + check_post(cdr); + if (cdr->disposition < AST_CDR_ANSWERED) + cdr->disposition = AST_CDR_ANSWERED; + if (ast_tvzero(cdr->answer)) + cdr->answer = ast_tvnow(); } } @@ -835,20 +832,30 @@ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *c) return 0; } +/* Three routines were "fixed" via 10668, and later shown that + users were depending on this behavior. ast_cdr_end, + ast_cdr_setvar and ast_cdr_answer are the three routines. + While most of the other routines would not touch + LOCKED cdr's, these three routines were designed to + operate on locked CDR's as a matter of course. + I now appreciate how this plays with the ForkCDR app, + which forms these cdr chains in the first place. + cdr_end is pretty key: all cdrs created are closed + together. They only vary by start time. Arithmetically, + users can calculate the subintervals they wish to track. */ + void ast_cdr_end(struct ast_cdr *cdr) { for ( ; cdr ; cdr = cdr->next) { - if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { - check_post(cdr); - if (ast_tvzero(cdr->end)) - cdr->end = ast_tvnow(); - if (ast_tvzero(cdr->start)) { - ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", S_OR(cdr->channel, "<unknown>")); - cdr->disposition = AST_CDR_FAILED; - } else - cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec; - cdr->billsec = ast_tvzero(cdr->answer) ? 0 : cdr->end.tv_sec - cdr->answer.tv_sec; - } + check_post(cdr); + if (ast_tvzero(cdr->end)) + cdr->end = ast_tvnow(); + if (ast_tvzero(cdr->start)) { + ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", S_OR(cdr->channel, "<unknown>")); + cdr->disposition = AST_CDR_FAILED; + } else + cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec; + cdr->billsec = ast_tvzero(cdr->answer) ? 0 : cdr->end.tv_sec - cdr->answer.tv_sec; } } |