[sr-dev] git:4.4:a5866ef9: acc: proper value for double representation of time for db accouting on 32b

Daniel-Constantin Mierla miconda at gmail.com
Tue Jun 28 12:40:39 CEST 2016


Module: kamailio
Branch: 4.4
Commit: a5866ef926ff6770227931c755188eb6178be07e
URL: https://github.com/kamailio/kamailio/commit/a5866ef926ff6770227931c755188eb6178be07e

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-06-28T12:40:18+02:00

acc: proper value for double representation of time for db accouting on 32b

(cherry picked from commit 4fe259ab61212bed926cff8380239980b4fe6b19)

---

Modified: modules/acc/acc.c

---

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

---

diff --git a/modules/acc/acc.c b/modules/acc/acc.c
index 430dca5..8d0d01c 100644
--- a/modules/acc/acc.c
+++ b/modules/acc/acc.c
@@ -443,6 +443,7 @@ int acc_db_request( struct sip_msg *rq)
 	int i;
 	int o;
 	struct tm *t;
+	double dtime;
 
 	/* formated database columns */
 	m = core2strar( rq, val_arr, int_arr, type_arr );
@@ -458,8 +459,9 @@ int acc_db_request( struct sip_msg *rq)
 		VAL_INT(db_vals+(m++)) = (int)acc_env.tv.tv_usec;
 		i++;
 	} else if(acc_time_mode==2) {
-		VAL_DOUBLE(db_vals+(m++)) = ((double)(acc_env.tv.tv_sec * 1000)
-							+ (acc_env.tv.tv_usec / 1000)) / 1000;
+		dtime = (double)acc_env.tv.tv_usec;
+		dtime = (dtime / 1000000) + (double)acc_env.tv.tv_sec;
+		VAL_DOUBLE(db_vals+(m++)) = dtime;
 		i++;
 	} else if(acc_time_mode==3 || acc_time_mode==4) {
 		if(acc_time_mode==3) {




More information about the sr-dev mailing list