]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
added v1.1 test_reachability option
authorwessels <>
Fri, 20 Mar 1998 13:51:43 +0000 (13:51 +0000)
committerwessels <>
Fri, 20 Mar 1998 13:51:43 +0000 (13:51 +0000)
src/cf.data.pre
src/comm.cc
src/icp_v2.cc
src/structs.h

index 71aeca29f5c24a02bad88e637da85d8c55906ce1..1556a41b106f65db4cea9894e7c3b116469e206e 100644 (file)
@@ -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
index a87bfdf8fd79498e076ba0a39975a77f38f537e4..2ac0a64f41eb3632fb7e329cb3b19b912097ccae 100644 (file)
@@ -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);
index 6386b1d687d092d02c67bbe434f44241398f7960..5b479f2ef4f8a1bea99a8b946dcd76fe91eb5425 100644 (file)
@@ -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);
index 1c074d2dc10cac16b148dd368f79f65546d1be21..d12cdf1028a0f6773fc2ea819e5ece04859c177b 100644 (file)
@@ -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 {