summaryrefslogtreecommitdiff
path: root/cdr/cdr_pgsql.c
diff options
context:
space:
mode:
authorBradley Latus <brad.latus@gmail.com>2010-06-08 23:48:17 +0000
committerBradley Latus <brad.latus@gmail.com>2010-06-08 23:48:17 +0000
commit4405813297fa41d441ab2cb28387df09b90aea68 (patch)
treeb9c0a6d9e565124104804ec2cb1e31a3c6b5ea41 /cdr/cdr_pgsql.c
parent3c26b511e03ac9dde860787f2cf3cf2ad06df495 (diff)
Add High Resolution Times to CDRs for Asterisk
People expressed an interest in having access to the exact length of calls to a finer degree than seconds. See the CHANGES and UPGRADE.txt for usage also updated the sample configs to note the change. Patch by snuffy. (closes issue #16559) Reported by: cianmaher Tested by: cianmaher, snuffy Review: https://reviewboard.asterisk.org/r/461/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@269153 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'cdr/cdr_pgsql.c')
-rw-r--r--cdr/cdr_pgsql.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index eae092642..53e957c26 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -211,12 +211,12 @@ static int pgsql_log(struct ast_cdr *cdr)
} else if (strncmp(cur->type, "float", 5) == 0) {
struct timeval *when = cur->name[0] == 'd' ? &cdr->start : &cdr->answer;
LENGTHEN_BUF2(31);
- ast_str_append(&sql2, 0, "%s%f", first ? "" : ",", (double)cdr->end.tv_sec - when->tv_sec + cdr->end.tv_usec / 1000000.0 - when->tv_usec / 1000000.0);
+ ast_str_append(&sql2, 0, "%s%f", first ? "" : ",", (double) (ast_tvdiff_us(cdr->end, *when) / 1000000.0));
} else {
/* Char field, probably */
struct timeval *when = cur->name[0] == 'd' ? &cdr->start : &cdr->answer;
LENGTHEN_BUF2(31);
- ast_str_append(&sql2, 0, "%s'%f'", first ? "" : ",", (double)cdr->end.tv_sec - when->tv_sec + cdr->end.tv_usec / 1000000.0 - when->tv_usec / 1000000.0);
+ ast_str_append(&sql2, 0, "%s'%f'", first ? "" : ",", (double) (ast_tvdiff_us(cdr->end, *when) / 1000000.0));
}
} else if (strcmp(cur->name, "disposition") == 0 || strcmp(cur->name, "amaflags") == 0) {
if (strncmp(cur->type, "int", 3) == 0) {