From 194dd3b8f0d12039e66e5d61fa90a4080f70acb4 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Fri, 20 Mar 1998 13:51:43 +0000 Subject: [PATCH] added v1.1 test_reachability option --- src/cf.data.pre | 13 +++++++++++++ src/comm.cc | 4 +++- src/icp_v2.cc | 14 ++++++++++++-- src/structs.h | 3 +++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/cf.data.pre b/src/cf.data.pre index 71aeca29f5..1556a41b10 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1838,6 +1838,19 @@ DOC_START query_icmp off DOC_END +NAME: test_rechability +COMMENT: on|off +TYPE: onoff +DEFAULT: off +LOC: Config.onoff.test_reachability +DOC_START + When this is 'on', ICP MISS replies will be ICP_MISS_NOFETCH + instead of ICP_MISS if the target host is NOT in the ICMP + database, or has a zero RTT. + +test_reachability off +DOC_END + NAME: buffered_logs COMMENT: on|off TYPE: onoff diff --git a/src/comm.cc b/src/comm.cc index a87bfdf8fd..2ac0a64f41 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.233 1998/03/07 05:50:15 wessels Exp $ + * $Id: comm.cc,v 1.234 1998/03/20 06:51:44 wessels Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -455,6 +455,8 @@ commConnectHandle(int fd, void *data) default: cs->tries++; ipcacheMarkBadAddr(cs->host, cs->S.sin_addr); + if (Config.onoff.test_reachability) + netdbDeleteAddrNetwork(cs->S.sin_addr); if (commRetryConnect(cs)) { cs->locks++; ipcache_nbgethostbyname(cs->host, commConnectDnsHandle, cs); diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 6386b1d687..5b479f2ef4 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -1,3 +1,4 @@ + #include "squid.h" static void icpLogIcp(icpUdpData *); @@ -144,6 +145,8 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) int src_rtt = 0; u_num32 flags = 0; method_t method; + int rtt = 0; + int hops = 0; xmemcpy(&header, buf, sizeof(icp_common_t)); /* * Only these fields need to be converted @@ -182,8 +185,8 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) break; } if (header.flags & ICP_FLAG_SRC_RTT) { - int rtt = netdbHostRtt(icp_request->host); - int hops = netdbHostHops(icp_request->host); + rtt = netdbHostRtt(icp_request->host); + hops = netdbHostHops(icp_request->host); src_rtt = ((hops & 0xFFFF) << 16) | (rtt & 0xFFFF); if (rtt) flags |= ICP_FLAG_SRC_RTT; @@ -197,6 +200,10 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) icpUdpSend(fd, &from, reply, LOG_UDP_HIT, icp_request->protocol); break; } + if (Config.onoff.test_reachability && rtt == 0) { + if ((rtt = netdbHostRtt(icp_request->host)) == 0) + netdbPingSite(icp_request->host); + } /* if store is rebuilding, return a UDP_HIT, but not a MISS */ if (store_rebuilding && opt_reload_hit_only) { reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt); @@ -204,6 +211,9 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) } else if (hit_only_mode_until > squid_curtime) { reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt); icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, icp_request->protocol); + } else if (Config.onoff.test_reachability && rtt == 0) { + reply = icpCreateMessage(ICP_MISS_NOFETCH, flags, url, header.reqnum, src_rtt); + icpUdpSend(fd, &from, reply, LOG_UDP_MISS_NOFETCH, icp_request->protocol); } else { reply = icpCreateMessage(ICP_MISS, flags, url, header.reqnum, src_rtt); icpUdpSend(fd, &from, reply, LOG_UDP_MISS, icp_request->protocol); diff --git a/src/structs.h b/src/structs.h index 1c074d2dc1..d12cdf1028 100644 --- a/src/structs.h +++ b/src/structs.h @@ -43,6 +43,7 @@ struct _acl_arp_data { acl_arp_data *next; #endif }; + #endif struct _String { @@ -95,6 +96,7 @@ typedef struct _usecEntry { int authWriteView; struct _usecEntry *next; } usecEntry; + #endif struct _acl { @@ -306,6 +308,7 @@ struct _SquidConfig { int announce; int accel_with_proxy; int mem_pools; + int test_reachability; } onoff; struct _acl *aclList; struct { -- 2.47.3