]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #2153: Use the cache_peer name in CARP hashing to support multiple peers on the...
authorhno <>
Mon, 14 Jan 2008 19:13:49 +0000 (19:13 +0000)
committerhno <>
Mon, 14 Jan 2008 19:13:49 +0000 (19:13 +0000)
The cache_peer name= option was introduced some years ago to allow
peers to be named and to suppot multiple peers on the same host/address.
However, carp still used the hostname/address and not the name making
it fail slightly when forwarding to multiple peers on the same address.

src/carp.cc

index 56e95e1b08ce0ed5d762ccde94a22fe8bcb4e0fd..9c7fa65324a297ac9631c487c83f54c14d0e4a80 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: carp.cc,v 1.26 2007/04/28 22:26:37 hno Exp $
+ * $Id: carp.cc,v 1.27 2008/01/14 12:13:49 hno Exp $
  *
  * DEBUG: section 39    Cache Array Routing Protocol
  * AUTHOR: Henrik Nordstrom
@@ -104,7 +104,7 @@ carpInit(void)
         /* calculate this peers hash */
         p->carp.hash = 0;
 
-        for (t = p->host; *t != 0; t++)
+        for (t = p->name; *t != 0; t++)
             p->carp.hash += ROTATE_LEFT(p->carp.hash, 19) + (unsigned int) *t;
 
         p->carp.hash += p->carp.hash * 0x62531965;
@@ -189,7 +189,7 @@ carpSelectParent(HttpRequest * request)
         combined_hash += combined_hash * 0x62531965;
         combined_hash = ROTATE_LEFT(combined_hash, 21);
         score = combined_hash * tp->carp.load_multiplier;
-        debugs(39, 3, "carpSelectParent: " << tp->host << " combined_hash " << combined_hash  << 
+        debugs(39, 3, "carpSelectParent: " << tp->name << " combined_hash " << combined_hash  << 
                " score " << std::setprecision(0) << score);
 
         if ((score > high_score) && peerHTTPOkay(tp, request)) {
@@ -199,7 +199,7 @@ carpSelectParent(HttpRequest * request)
     }
 
     if (p)
-        debugs(39, 2, "carpSelectParent: selected " << p->host);
+        debugs(39, 2, "carpSelectParent: selected " << p->name);
 
     return p;
 }
@@ -221,7 +221,7 @@ carpCachemgr(StoreEntry * sentry)
 
     for (p = Config.peers; p; p = p->next) {
         storeAppendPrintf(sentry, "%24s %10x %10f %10f %10f\n",
-                          p->host, p->carp.hash,
+                          p->name, p->carp.hash,
                           p->carp.load_multiplier,
                           p->carp.load_factor,
                           sumfetches ? (double) p->stats.fetches / sumfetches : -1.0);