[sr-dev] git:master:0c6653bf: acc: don't multiply seconds with 1000 for time mode 2

Daniel-Constantin Mierla miconda at gmail.com
Thu Jun 23 07:26:51 CEST 2016


Module: kamailio
Branch: master
Commit: 0c6653bf1c3ee7b64e811bc752e03fa0adfb0dfe
URL: https://github.com/kamailio/kamailio/commit/0c6653bf1c3ee7b64e811bc752e03fa0adfb0dfe

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-06-23T07:25:47+02:00

acc: don't multiply seconds with 1000 for time mode 2

- it can go out of range for 32bit arch

---

Modified: modules/acc/acc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/0c6653bf1c3ee7b64e811bc752e03fa0adfb0dfe.diff
Patch: https://github.com/kamailio/kamailio/commit/0c6653bf1c3ee7b64e811bc752e03fa0adfb0dfe.patch

---

diff --git a/modules/acc/acc.c b/modules/acc/acc.c
index 7bf7dd7..430dca5 100644
--- a/modules/acc/acc.c
+++ b/modules/acc/acc.c
@@ -232,6 +232,7 @@ int acc_log_request( struct sip_msg *rq)
 	int o;
 	int i;
 	struct tm *t;
+	double dtime;
 
 	/* get default values */
 	m = core2strar( rq, val_arr, int_arr, type_arr);
@@ -290,12 +291,11 @@ int acc_log_request( struct sip_msg *rq)
 			acc_time_exten.s, (unsigned int)acc_env.tv.tv_usec,
 			log_msg);
 	} else if(acc_time_mode==2) {
+		dtime = (double)acc_env.tv.tv_usec;
+		dtime = (dtime / 1000000) + (double)acc_env.tv.tv_sec;
 		LM_GEN2(log_facility, log_level, "%.*stimestamp=%lu;%s=%.3f%s",
 			acc_env.text.len, acc_env.text.s,(unsigned long)acc_env.ts,
-			acc_time_attr.s,
-			(((double)(acc_env.tv.tv_sec * 1000)
-							+ (acc_env.tv.tv_usec / 1000)) / 1000),
-			log_msg);
+			acc_time_attr.s, dtime, log_msg);
 	} else if(acc_time_mode==3 || acc_time_mode==4) {
 		if(acc_time_mode==3) {
 			t = localtime(&acc_env.ts);




More information about the sr-dev mailing list