/*
- * $Id: stat.cc,v 1.334 2000/09/05 19:40:18 wessels Exp $
+ * $Id: stat.cc,v 1.335 2000/10/03 20:51:04 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
{
size_t s;
size_t c;
+#if USE_CACHE_DIGESTS
+ size_t cd;
+#endif
+ /* size_t might be unsigned */
assert(minutes < N_COUNT_HIST);
c = CountHist[0].client_http.kbytes_out.kb - CountHist[minutes].client_http.kbytes_out.kb;
s = CountHist[0].server.all.kbytes_in.kb - CountHist[minutes].server.all.kbytes_in.kb;
- /* size_t might be unsigned */
+#if USE_CACHE_DIGESTS
+ /*
+ * This ugly hack is here to prevent the user from seeing a
+ * negative byte hit ratio. When we fetch a cache digest from
+ * a neighbor, it gets treated like a cache miss because the
+ * object is consumed internally. Thus, we subtract cache
+ * digest bytes out before calculating the byte hit ratio.
+ */
+ cd = CountHist[0].cd.kbytes_recv.kb - CountHist[minutes].cd.kbytes_recv.kb;
+ assert(s > cd);
+ s -= cd;
+#endif
if (c > s)
return dpercent(c - s, c);
else