From 8953b0f3594eb43530530162729f7cee19e07db0 Mon Sep 17 00:00:00 2001 From: Steve Murphy Date: Tue, 26 Aug 2008 15:57:49 +0000 Subject: (closes issue #13366) Reported by: erousseau This was a reasonable enhancement request, which was easy to implement. Since it's an enhancement, it could only be applied to trunk. Basically, for accounting where "initiated" seconds are billed for, if the microseconds field on the end time is greater than the microseconds field for the answer time, add one second to the billsec field. The implementation was requested by erousseau, and I've implemented it as requested. I've updated the CHANGES, the cdr.conf.sample, and the .h files accordingly, to accept and set a flag for the corresponding new option. cdr.c adds in the extra second based on the usec fields if the option is set. Tested, seems to be working fine. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@140057 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/cdr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'main') diff --git a/main/cdr.c b/main/cdr.c index 6bf60b8a7..111c3daf0 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -874,8 +874,11 @@ void ast_cdr_end(struct ast_cdr *cdr) ast_log(LOG_WARNING, "CDR on channel '%s' has no answer time but is 'ANSWERED'\n", S_OR(cdr->channel, "")); cdr->disposition = AST_CDR_FAILED; } - } else + } else { cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec; + if (ast_test_flag(&ast_options, AST_OPT_FLAG_INITIATED_SECONDS)) + cdr->billsec += cdr->end.tv_usec > cdr->answer.tv_usec ? 1 : 0; + } } } @@ -1386,6 +1389,7 @@ static int do_reload(int reload) const char *size_value; const char *time_value; const char *end_before_h_value; + const char *initiatedseconds_value; int cfg_size; int cfg_time; int was_enabled; @@ -1444,6 +1448,8 @@ static int do_reload(int reload) } if ((end_before_h_value = ast_variable_retrieve(config, "general", "endbeforehexten"))) ast_set2_flag(&ast_options, ast_true(end_before_h_value), AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN); + if ((initiatedseconds_value = ast_variable_retrieve(config, "general", "initiatedseconds"))) + ast_set2_flag(&ast_options, ast_true(initiatedseconds_value), AST_OPT_FLAG_INITIATED_SECONDS); } if (enabled && !batchmode) { -- cgit v1.2.3