ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", chan);
if (ast_tvzero(cdr->end))
cdr->end = ast_tvnow();
+ cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec + (cdr->end.tv_usec - cdr->start.tv_usec) / 1000000;
+ if (!ast_tvzero(cdr->answer))
+ cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec + (cdr->end.tv_usec - cdr->answer.tv_usec) / 1000000;
+ else
+ cdr->billsec = 0;
cdr = cdr->next;
}
}
ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan);
if (ast_tvzero(cdr->start))
ast_log(LOG_WARNING, "CDR on channel '%s' lacks start\n", chan);
- cdr->duration = cdr->end.tv_sec - cdr->start.tv_sec + (cdr->end.tv_usec - cdr->start.tv_usec) / 1000000;
- if (!ast_tvzero(cdr->answer))
- cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec + (cdr->end.tv_usec - cdr->answer.tv_usec) / 1000000;
- else
- cdr->billsec = 0;
ast_set_flag(cdr, AST_CDR_FLAG_POSTED);
AST_LIST_LOCK(&be_list);
AST_LIST_TRAVERSE(&be_list, i, list) {
const char *batchsafeshutdown_value;
const char *size_value;
const char *time_value;
+ const char *end_before_h_value;
int cfg_size;
int cfg_time;
int was_enabled;
else
batchtime = cfg_time;
}
+ if ((end_before_h_value = ast_variable_retrieve(config, "general", "endbeforehexten")))
+ ast_set2_flag(&ast_options, ast_true(end_before_h_value), AST_OPT_END_CDR_BEFORE_H_EXTEN);
}
if (enabled && !batchmode) {
; is "yes".
;safeshutdown=yes
;
+
+; Normally, CDR's are not closed out until after all extensions are finished
+; executing. By enabling this option, the CDR will be ended before executing
+; the "h" extension so that CDR values such as "end" and "billsec" may be
+; retrieved inside of of this extension.
+;endbeforehexten=no
+
;[csv]
;usegmtime=yes ;log date/time in GMT
;loguniqueid=yes ;log uniqueid
/*! Transmit Silence during Record() */
AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17),
/*! Suppress some warnings */
- AST_OPT_FLAG_DONT_WARN = (1 << 18)
+ AST_OPT_FLAG_DONT_WARN = (1 << 18),
+ /*! End CDRs before the 'h' extension */
+ AST_OPT_END_CDR_BEFORE_H_EXTEN = (1 << 19)
};
#define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
+#define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_END_CDR_BEFORE_H_EXTEN)
extern struct ast_flags ast_options;
ast_log(LOG_WARNING, "Don't know what to do with '%s'\n", c->name);
out:
if ((res != AST_PBX_KEEPALIVE) && ast_exists_extension(c, c->context, "h", 1, c->cid.cid_num)) {
+ if (c->cdr && ast_opt_end_cdr_before_h_exten)
+ ast_cdr_end(c->cdr);
c->exten[0] = 'h';
c->exten[1] = '\0';
c->priority = 1;