aboutsummaryrefslogtreecommitdiffstats
path: root/main/cdr.c
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-03 00:16:25 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-03 00:16:25 +0000
commit61b6de4e16736df453e61eead1ac1c574305e0f5 (patch)
treef2c79c5941fdf5b648ecb85706407379e93a3dd4 /main/cdr.c
parent213226fe9aec511d36531d2677b36785057144c6 (diff)
The CDRfix4/5/6 omnibus cdr fixes.
(closes issue #10927) Reported by: murf Tested by: murf, deeperror (closes issue #12907) Reported by: falves11 Tested by: murf, falves11 (closes issue #11849) Reported by: greyvoip As to 11849, I think these changes fix the core problems brought up in that bug, but perhaps not the more global problems created by the limitations of CDR's themselves not being oriented around transfers. Reopen if necc, but bug reports are not the best medium for enhancement discussions. We need to start a second-generation CDR standardization effort to cover transfers. (closes issue #11093) Reported by: rossbeer Tested by: greyvoip, murf git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@127663 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/cdr.c')
-rw-r--r--main/cdr.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/main/cdr.c b/main/cdr.c
index 45e39b6eb..1e57efbff 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -785,6 +785,10 @@ void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data)
for (; cdr; cdr = cdr->next) {
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
check_post(cdr);
+ if (!app)
+ app = "";
+ if (!data)
+ data = "";
ast_copy_string(cdr->lastapp, S_OR(app, ""), sizeof(cdr->lastapp));
ast_copy_string(cdr->lastdata, S_OR(data, ""), sizeof(cdr->lastdata));
}
@@ -868,7 +872,13 @@ void ast_cdr_end(struct ast_cdr *cdr)
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;
+ if (ast_tvzero(cdr->answer)) {
+ if (cdr->disposition == AST_CDR_ANSWERED) {
+ ast_log(LOG_WARNING, "CDR on channel '%s' has no answer time but is 'ANSWERED'\n", S_OR(cdr->channel, "<unknown>"));
+ cdr->disposition = AST_CDR_FAILED;
+ }
+ } else
+ cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec;
}
}
@@ -1056,6 +1066,27 @@ void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags)
}
}
+void ast_cdr_specialized_reset(struct ast_cdr *cdr, struct ast_flags *_flags)
+{
+ struct ast_flags flags = { 0 };
+
+ if (_flags)
+ ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);
+
+ if (_flags)
+ ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);
+
+ /* Reset to initial state */
+ ast_clear_flag(cdr, AST_FLAGS_ALL);
+ memset(&cdr->start, 0, sizeof(cdr->start));
+ memset(&cdr->end, 0, sizeof(cdr->end));
+ memset(&cdr->answer, 0, sizeof(cdr->answer));
+ cdr->billsec = 0;
+ cdr->duration = 0;
+ ast_cdr_start(cdr);
+ cdr->disposition = AST_CDR_NULL;
+}
+
struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr)
{
struct ast_cdr *ret;