]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
initial CACHE_DIGEST code
authorwessels <>
Sat, 4 Apr 1998 07:24:06 +0000 (07:24 +0000)
committerwessels <>
Sat, 4 Apr 1998 07:24:06 +0000 (07:24 +0000)
src/enums.h
src/peer_select.cc
src/structs.h

index 4294742fff440fdfe02bba99dde5d0162cbe3abe..07b1c9240eb62e7f8566d3fbca1fc981729518af 100644 (file)
@@ -248,6 +248,9 @@ typedef enum {
     NO_DIRECT_FAIL,
     SOURCE_FASTEST,
     ROUNDROBIN_PARENT,
+#if CACHE_DIGEST
+    CACHE_DIGEST_HIT,
+#endif
     HIER_MAX
 } hier_code;
 
index 67009ccc4294011023e4bffbdfb9492d1f652608..c761a0390d32c55248f6bfd3f35ccb3ec75e7858 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_select.cc,v 1.43 1998/04/01 05:38:59 wessels Exp $
+ * $Id: peer_select.cc,v 1.44 1998/04/04 00:24:06 wessels Exp $
  *
  * DEBUG: section 44    Peer Selection Algorithm
  * AUTHOR: Duane Wessels
@@ -47,6 +47,9 @@ const char *hier_strings[] =
     "NO_DIRECT_FAIL",
     "SOURCE_FASTEST",
     "ROUNDROBIN_PARENT",
+#if CACHE_DIGEST
+    "CACHE_DIGEST_HIT",
+#endif
     "INVALID CODE"
 };
 
@@ -300,23 +303,41 @@ peerSelectFoo(ps_state * psstate)
        debug(44, 3) ("peerSelect: found single parent, skipping ICP query\n");
     } else if (peerSelectIcpPing(request, direct, entry)) {
        assert(entry->ping_status == PING_NONE);
-       debug(44, 3) ("peerSelect: Doing ICP pings\n");
-        psstate->icp.start = current_time;
-       psstate->icp.n_sent = neighborsUdpPing(request,
-           entry,
-           peerHandleIcpReply,
-           psstate,
-           &psstate->icp.n_replies_expected);
-       if (psstate->icp.n_sent == 0)
-           debug(44, 0) ("WARNING: neighborsUdpPing returned 0\n");
-       if (psstate->icp.n_replies_expected > 0) {
-           entry->ping_status = PING_WAITING;
-           eventAdd("peerPingTimeout",
-               peerPingTimeout,
+#if CACHE_DIGEST
+       if (squid_random() & 1) {
+           debug(44, 3) ("peerSelect: Using Cache Digest\n");
+           request->hier.used_cd = 1;
+           p == cacheDigestSelect(request, entry);
+           if (NULL != p) {
+               request->hier.cd_hit = 1;
+               code = CACHE_DIGEST_HIT;
+               debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], p->host);
+               hierarchyNote(&request->hier, code, &psstate->icp, p->host);
+               peerSelectCallback(psstate, NULL);
+           }
+       } else {
+           request->hier.used_icp = 1;
+#endif
+           debug(44, 3) ("peerSelect: Doing ICP pings\n");
+           psstate->icp.start = current_time;
+           psstate->icp.n_sent = neighborsUdpPing(request,
+               entry,
+               peerHandleIcpReply,
                psstate,
-               Config.neighborTimeout);
-           return;
+               &psstate->icp.n_replies_expected);
+           if (psstate->icp.n_sent == 0)
+               debug(44, 0) ("WARNING: neighborsUdpPing returned 0\n");
+           if (psstate->icp.n_replies_expected > 0) {
+               entry->ping_status = PING_WAITING;
+               eventAdd("peerPingTimeout",
+                   peerPingTimeout,
+                   psstate,
+                   Config.neighborTimeout);
+               return;
+           }
+#if CACHE_DIGEST
        }
+#endif
     }
     debug(44, 3) ("peerSelectFoo: After peerSelectIcpPing.\n");
     if (peerCheckNetdbDirect(psstate)) {
index c6340b1ece6cd6de495f064b12251f9485bf9ba9..d08cbca21a602c0ac6ebedc686cd441b0a1a8bf2 100644 (file)
@@ -611,6 +611,11 @@ struct _HierarchyLogEntry {
     hier_code code;
     char host[SQUIDHOSTNAMELEN];
     icp_ping_data icp;
+#if CACHE_DIGEST
+    int used_cd;
+    int used_icp;
+    int cd_hit;
+#endif
 };
 
 struct _AccessLogEntry {
@@ -1126,6 +1131,10 @@ struct _StatCounters {
        kb_t kbytes_recv;
        StatHist query_svc_time;
        StatHist reply_svc_time;
+#if CACHE_DIGEST
+       StatHist client_svc_time;
+       int times_used;
+#endif
     } icp;
     struct {
        int requests;
@@ -1133,6 +1142,19 @@ struct _StatCounters {
     struct {
        StatHist svc_time;
     } dns;
+#if CACHE_DIGEST
+    struct {
+       int times_used;
+       int true_hits;
+       int false_hits;
+       int true_misses;
+       int false_misses;
+       kb_t kbtes_sent;
+       kb_t kbtes_recv;
+       kb_t memory;
+       StatHist client_svc_time;
+    } cd;
+#endif
     int page_faults;
     int select_loops;
     double cputime;