You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2005/06/14 08:34:13 UTC
cvs commit: jakarta-tomcat-connectors/jk/native/common jk_global.h jk_lb_worker.c jk_shm.h jk_status.c
mturk 2005/06/13 23:34:13
Modified: jk/native/common jk_global.h jk_lb_worker.c jk_shm.h
jk_status.c
Log:
Use 64 bit unsigned ints instead doubles for transferred/read.
Revision Changes Path
1.50 +4 -1 jakarta-tomcat-connectors/jk/native/common/jk_global.h
Index: jk_global.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_global.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- jk_global.h 18 May 2005 18:04:53 -0000 1.49
+++ jk_global.h 14 Jun 2005 06:34:13 -0000 1.50
@@ -253,6 +253,9 @@
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#endif
+typedef unsigned __int64 jk_u64_t;
+#else
+typedef unsigned long long jk_u64_t;
#endif
/* Use apr snprintf() and vsnprintf() when needed */
1.91 +5 -5 jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c
Index: jk_lb_worker.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_lb_worker.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -r1.90 -r1.91
--- jk_lb_worker.c 13 Jun 2005 07:55:51 -0000 1.90
+++ jk_lb_worker.c 14 Jun 2005 06:34:13 -0000 1.91
@@ -225,8 +225,8 @@
{
unsigned int i;
int total_factor = 0;
- double mytraffic = 0;
- double curmin = 0;
+ jk_u64_t mytraffic = 0;
+ jk_u64_t curmin = 0;
worker_record_t *candidate = NULL;
if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
@@ -313,8 +313,8 @@
jk_logger_t *l)
{
unsigned int i;
- double mytraffic = 0;
- double curmin = 0;
+ jk_u64_t mytraffic = 0;
+ jk_u64_t curmin = 0;
worker_record_t *candidate = NULL;
if (p->lblock == JK_LB_LOCK_PESSIMISTIC)
1.22 +3 -3 jakarta-tomcat-connectors/jk/native/common/jk_shm.h
Index: jk_shm.h
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_shm.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- jk_shm.h 13 Jun 2005 07:55:51 -0000 1.21
+++ jk_shm.h 14 Jun 2005 06:34:13 -0000 1.22
@@ -81,9 +81,9 @@
/* Statistical data */
volatile time_t error_time;
/* Number of bytes read from remote */
- volatile double readed;
+ volatile jk_u64_t readed;
/* Number of bytes transferred to remote */
- volatile double transferred;
+ volatile jk_u64_t transferred;
/* Number of times the worker was elected */
volatile size_t elected;
/* Number of non 200 responses */
1.43 +16 -4 jakarta-tomcat-connectors/jk/native/common/jk_status.c
Index: jk_status.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_status.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- jk_status.c 13 Jun 2005 07:55:51 -0000 1.42
+++ jk_status.c 14 Jun 2005 06:34:13 -0000 1.43
@@ -166,10 +166,11 @@
}
/* Actually APR's apr_strfsize */
-static char *status_strfsize(double size, char *buf)
+static char *status_strfsize(jk_u64_t size, char *buf)
{
const char ord[] = "KMGTPE";
const char *o = ord;
+ unsigned int remain, siz;
if (size < 0) {
return strcpy(buf, " - ");
@@ -180,12 +181,23 @@
return buf;
}
do {
- size /= 1024;
+ remain = (unsigned int)(size & 0x03FF);
+ size >>= 10;
if (size >= 973) {
++o;
continue;
}
- if (sprintf(buf, "%.2f%c", size, *o) < 0)
+ siz = (unsigned int)(size & 0xFFFF);
+ if (siz < 9 || (siz == 9 && remain < 973)) {
+ if ((remain = ((remain * 5) + 256) / 512) >= 10)
+ ++siz, remain = 0;
+ if (sprintf(buf, "%d.%d%c", siz, remain, *o) < 0)
+ return strcpy(buf, "****");
+ return buf;
+ }
+ if (remain >= 512)
+ ++siz;
+ if (sprintf(buf, "%3d%c", siz, *o) < 0)
return strcpy(buf, "****");
return buf;
} while (1);
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org