From e4cc2fdf469bd0753a74fb8b9f26baabf30d9a96 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Tue, 10 Oct 2000 08:10:42 +0000 Subject: [PATCH] DW: - Changed "WARNING: swapin MD5 mismatch" logging so that it is printed only on powers of ten, just like "ignored XX replies non-peer" messages in neighbors.c. --- src/neighbors.cc | 12 ++++-------- src/protos.h | 3 ++- src/store_client.cc | 12 ++++++++---- src/tools.cc | 16 +++++++++++++++- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/neighbors.cc b/src/neighbors.cc index a98e7b84d5..7cca72e6b0 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.285 2000/10/04 01:13:25 wessels Exp $ + * $Id: neighbors.cc,v 1.286 2000/10/10 02:10:42 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -701,7 +701,6 @@ static void neighborIgnoreNonPeer(const struct sockaddr_in *from, icp_opcode opcode) { peer *np; - double x; for (np = non_peers; np; np = np->next) { if (np->in_addr.sin_addr.s_addr != from->sin_addr.s_addr) continue; @@ -719,13 +718,10 @@ neighborIgnoreNonPeer(const struct sockaddr_in *from, icp_opcode opcode) np->next = non_peers; non_peers = np; } - np->stats.ignored_replies++; np->icp.counts[opcode]++; - x = log(np->stats.ignored_replies) / log(10.0); - if (0.0 != x - (double) (int) x) - return; - debug(15, 1) ("WARNING: Ignored %d replies from non-peer %s\n", - np->stats.ignored_replies, np->host); + if (isPowTen(++np->stats.ignored_replies)) + debug(15, 1) ("WARNING: Ignored %d replies from non-peer %s\n", + np->stats.ignored_replies, np->host); } /* ignoreMulticastReply diff --git a/src/protos.h b/src/protos.h index 58a20fbb5c..df34490757 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.380 2000/10/04 15:32:13 wessels Exp $ + * $Id: protos.h,v 1.381 2000/10/10 02:10:42 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1072,6 +1072,7 @@ extern int stringHasCntl(const char *); extern void linklistPush(link_list **, void *); extern void *linklistShift(link_list **); extern int xrename(const char *from, const char *to); +extern int isPowTen(int); #if USE_HTCP extern void htcpInit(void); diff --git a/src/store_client.cc b/src/store_client.cc index 4edad8e8a9..3336913c58 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.96 2000/10/09 18:37:10 wessels Exp $ + * $Id: store_client.cc,v 1.97 2000/10/10 02:10:43 wessels Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -371,6 +371,7 @@ storeClientReadBody(void *data, const char *buf, ssize_t len) static void storeClientReadHeader(void *data, const char *buf, ssize_t len) { + static int md5_mismatches = 0; store_client *sc = data; StoreEntry *e = sc->entry; MemObject *mem = e->mem_obj; @@ -410,9 +411,12 @@ storeClientReadHeader(void *data, const char *buf, ssize_t len) assert(t->length == MD5_DIGEST_CHARS); if (!EBIT_TEST(e->flags, KEY_PRIVATE) && memcmp(t->value, e->key, MD5_DIGEST_CHARS)) { - debug(20, 1) ("WARNING: swapin MD5 mismatch\n"); - debug(20, 1) ("\t%s\n", storeKeyText(t->value)); - debug(20, 1) ("\t%s\n", storeKeyText(e->key)); + debug(20, 2) ("storeClientReadHeader: swapin MD5 mismatch\n"); + debug(20, 2) ("\t%s\n", storeKeyText(t->value)); + debug(20, 2) ("\t%s\n", storeKeyText(e->key)); + if (isPowTen(++md5_mismatches)) + debug(20, 1) ("WARNING: %d swapin MD5 mismatches\n", + md5_mismatches); swap_object_ok = 0; } break; diff --git a/src/tools.cc b/src/tools.cc index 72a6647953..b25f2a225e 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.195 2000/09/16 21:47:46 hno Exp $ + * $Id: tools.cc,v 1.196 2000/10/10 02:10:43 wessels Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -908,3 +908,17 @@ stringHasCntl(const char *s) } return 0; } + +/* + * isPowTen returns true if its argument is an integer power of + * 10. Its used for logging of certain error messages that can + * occur often, but that we don't want to fill cache.log with. + */ +int +isPowTen(int count) +{ + double x = log(count) / log(10.0); + if (0.0 != x - (double) (int) x) + return 0; + return 1; +} -- 2.47.2