]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
always divide percent by at least 100
authorwessels <>
Tue, 15 Oct 1996 13:44:02 +0000 (13:44 +0000)
committerwessels <>
Tue, 15 Oct 1996 13:44:02 +0000 (13:44 +0000)
src/client_db.cc

index 8d5e4e2f719212b7f1ea6ea880de6a9112bc6e7f..08a176baaa8e6bb9425456d596dfbf944d9814ab 100644 (file)
@@ -59,10 +59,13 @@ int
 clientdbDeniedPercent(struct in_addr addr)
 {
     char *key = inet_ntoa(addr);
+    int n = 100;
     ClientInfo *c = (ClientInfo *) hash_lookup(client_table, key);
     if (c == NULL)
        return 0;
-    return 100 * c->result_hist[ICP_OP_DENIED] / c->n_icp;
+    if (c->n_icp > 100)
+       n = c->n_icp;
+    return 100 * c->result_hist[ICP_OP_DENIED] / n;
 }
 
 void
@@ -89,6 +92,7 @@ clientdbDump(StoreEntry * sentry)
                c->result_hist[l],
                percent(c->result_hist[l], c->n_requests));
        }
+       storeAppendPrintf(sentry, "{}\n");
        c = (ClientInfo *) hash_next(client_table);
     }
     storeAppendPrintf(sentry, close_bracket);