]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 369369 via svnmerge from
authorAutomerge script <automerge@asterisk.org>
Mon, 25 Jun 2012 20:21:57 +0000 (20:21 +0000)
committerAutomerge script <automerge@asterisk.org>
Mon, 25 Jun 2012 20:21:57 +0000 (20:21 +0000)
file:///srv/subversion/repos/asterisk/branches/10

................
  r369369 | mjordan | 2012-06-25 14:36:02 -0500 (Mon, 25 Jun 2012) | 29 lines

  Fix incorrect duration reporting in CDRs created in batch mode

  Certain places in core/cdr.c would, if the duration value were 0, calculate the
  duration as being the delta between the current time and the time at which the
  CDR record was started.  While this does not typically cause a problem in
  non-batch mode, this can cause an issue in batch mode where CDR records are
  gathered and written long after those calls have ended. In particular, this
  affects calls that were never answered, as those are expected to have a duration
  of 0.  Often, this would result in CDR logs with a significant number of calls
  with lengthy durations, but dispositions of "BUSY".

  Note that this does not affect cdr_csv, as that backend does not use
  ast_cdr_getvar and instead directly reports the duration value.  The affected
  core backends include cdr_apative_odbc and cdr_custom; other extended or
  deprecated CDR backends may potentially still directly manipulate the duration
  values.

  (issue ASTERISK-19860)
  Reported by: Thomas Arimont

  (issue AST-883)
  Reported by: Thomas Arimont
  Tested by: Matt Jordan

  Review: https://reviewboard.asterisk.org/r/1996/
  ........

  Merged revisions 369351 from http://svn.asterisk.org/svn/asterisk/branches/1.8
................

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@369384 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/cdr.c

index 755a1b3c6a6c6c8d8483f32da5a6f8e137679077..08fa3d09417cfd78c3daeb31409f2ac201c6490d 100644 (file)
@@ -293,9 +293,9 @@ void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *wor
                cdr_get_tv(cdr->answer, raw ? NULL : fmt, workspace, workspacelen);
        else if (!strcasecmp(name, "end"))
                cdr_get_tv(cdr->end, raw ? NULL : fmt, workspace, workspacelen);
-       else if (!strcasecmp(name, "duration"))
-               snprintf(workspace, workspacelen, "%ld", cdr->duration ? cdr->duration : (long)ast_tvdiff_ms(ast_tvnow(), cdr->start) / 1000);
-       else if (!strcasecmp(name, "billsec"))
+       else if (!strcasecmp(name, "duration")) {
+               snprintf(workspace, workspacelen, "%ld", cdr->end.tv_sec != 0 ? cdr->duration : (long)ast_tvdiff_ms(ast_tvnow(), cdr->start) / 1000);
+       else if (!strcasecmp(name, "billsec"))
                snprintf(workspace, workspacelen, "%ld", cdr->billsec || cdr->answer.tv_sec == 0 ? cdr->billsec : (long)ast_tvdiff_ms(ast_tvnow(), cdr->answer) / 1000);
        else if (!strcasecmp(name, "disposition")) {
                if (raw) {