[asterisk-commits] mjordan: branch certified-1.8.11 r374847 - in /certified/branches/1.8.11: ./ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 11 10:46:31 CDT 2012


Author: mjordan
Date: Thu Oct 11 10:46:29 2012
New Revision: 374847

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=374847
Log:
Fix incorrect billing duration reported when batch mode is enabled

Similar to r369351, the billing duration can be skewed when batch mode is
enabled.  This happened much more rarely than the duration, as it only
occured when the call was answered (thereby indicating an actual answer
time) and immediately hung up on (indicating a billsec of 0).  Since
a billing time of '0' can either mean that the call immediately ended
or that the CDR was improperly answered, we have to use additional information
to know whether or not we can trust the CDR billsec value.  Prior to this
patch, we looked to see if we had a valid answer time.  If we did, and
billsec was zero, we used the current time to calculate what billsec value
we could from the CDR being written.  If batch mode is enabled, this will
incorrectly report a billsec value being much greater than the actual
duration of the call.

Instead of relying on the presence of an answer time to know whether or not
we can re-calculate the billsec for the CDR, we now also use the presence
of the CDR's end time to know if we need to re-calculate or whether we can
trust the billsec value that we have.  This prevents erroneous jumps in the
billsec value, while still making sure that in the worst case, some billing
time will be calculated.

(closes issue AST-1016)
Reported by: Thomas Arimont
Tested by: Thomas Arimont
........

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

Modified:
    certified/branches/1.8.11/   (props changed)
    certified/branches/1.8.11/main/cdr.c

Propchange: certified/branches/1.8.11/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: certified/branches/1.8.11/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/1.8.11/main/cdr.c?view=diff&rev=374847&r1=374846&r2=374847
==============================================================================
--- certified/branches/1.8.11/main/cdr.c (original)
+++ certified/branches/1.8.11/main/cdr.c Thu Oct 11 10:46:29 2012
@@ -291,9 +291,9 @@
 		cdr_get_tv(cdr->end, raw ? NULL : fmt, workspace, workspacelen);
 	else if (!strcasecmp(name, "duration")) {
 		snprintf(workspace, workspacelen, "%ld", cdr->duration || !ast_tvzero(cdr->end) ? 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")) {
+	} else if (!strcasecmp(name, "billsec")) {
+		snprintf(workspace, workspacelen, "%ld", (cdr->billsec || !ast_tvzero(cdr->end) || ast_tvzero(cdr->answer)) ? cdr->billsec : (long)ast_tvdiff_ms(ast_tvnow(), cdr->answer) / 1000);	
+	} else if (!strcasecmp(name, "disposition")) {
 		if (raw) {
 			snprintf(workspace, workspacelen, "%ld", cdr->disposition);
 		} else {




More information about the asterisk-commits mailing list