[asterisk-commits] trunk r12896 - in /trunk: ./ configs/ include/asterisk/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Mar 14 09:49:42 MST 2006


Author: russell
Date: Tue Mar 14 10:49:34 2006
New Revision: 12896

URL: http://svn.digium.com/view/asterisk?rev=12896&view=rev
Log:
add an option to cdr.conf that enables ending CDRs before executing
the "h" extension as opposed to afterwards (issue #6193)

Modified:
    trunk/cdr.c
    trunk/configs/cdr.conf.sample
    trunk/include/asterisk/options.h
    trunk/pbx.c

Modified: trunk/cdr.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr.c?rev=12896&r1=12895&r2=12896&view=diff
==============================================================================
--- trunk/cdr.c (original)
+++ trunk/cdr.c Tue Mar 14 10:49:34 2006
@@ -657,6 +657,11 @@
 			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;
 	}
 }
@@ -804,11 +809,6 @@
 			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) {
@@ -1121,6 +1121,7 @@
 	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;
@@ -1171,6 +1172,8 @@
 			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) {

Modified: trunk/configs/cdr.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/cdr.conf.sample?rev=12896&r1=12895&r2=12896&view=diff
==============================================================================
--- trunk/configs/cdr.conf.sample (original)
+++ trunk/configs/cdr.conf.sample Tue Mar 14 10:49:34 2006
@@ -49,6 +49,13 @@
 ; 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

Modified: trunk/include/asterisk/options.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/options.h?rev=12896&r1=12895&r2=12896&view=diff
==============================================================================
--- trunk/include/asterisk/options.h (original)
+++ trunk/include/asterisk/options.h Tue Mar 14 10:49:34 2006
@@ -69,7 +69,9 @@
 	/*! 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)
@@ -91,6 +93,7 @@
 #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;
 

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=12896&r1=12895&r2=12896&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Tue Mar 14 10:49:34 2006
@@ -2278,6 +2278,8 @@
 		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;



More information about the asterisk-commits mailing list