aboutsummaryrefslogtreecommitdiffstats
path: root/main/cdr.c
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-29 01:29:09 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-29 01:29:09 +0000
commite99b6bfc85aed2ae9738e460395abcccb0a18c34 (patch)
treeb0d4b1a7af0389916a6912eca44db476aa159f36 /main/cdr.c
parente6d77dc5793cb16b85ddeb0c3c3491d01a27ddbc (diff)
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/trunk@118880 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/cdr.c')
-rw-r--r--main/cdr.c73
1 files changed, 40 insertions, 33 deletions
diff --git a/main/cdr.c b/main/cdr.c
index 3c45baf85..0a91f74fd 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;
}
}