--------------------- PatchSet 11506 Date: 2008/02/26 00:04:15 Author: Amos Jeffries Branch: SQUID_3_0 Tag: (none) Log: Author: Henrik Nordstrom Bug #2153: Use the cache_peer name in CARP hashing to support multiple peers on the same host 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. Members: src/carp.cc:1.26->1.26.4.1 Index: squid3/src/carp.cc =================================================================== RCS file: /cvsroot/squid/squid3/src/carp.cc,v retrieving revision 1.26 retrieving revision 1.26.4.1 diff -u -r1.26 -r1.26.4.1 --- squid3/src/carp.cc 28 Apr 2007 22:26:37 -0000 1.26 +++ squid3/src/carp.cc 26 Feb 2008 00:04:15 -0000 1.26.4.1 @@ -1,6 +1,6 @@ /* - * $Id: carp.cc,v 1.26 2007/04/28 22:26:37 hno Exp $ + * $Id: carp.cc,v 1.26.4.1 2008/02/26 00:04:15 amosjeffries Exp $ * * DEBUG: section 39 Cache Array Routing Protocol * AUTHOR: Henrik Nordstrom @@ -104,7 +104,7 @@ /* 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 @@ 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 @@ } if (p) - debugs(39, 2, "carpSelectParent: selected " << p->host); + debugs(39, 2, "carpSelectParent: selected " << p->name); return p; } @@ -221,7 +221,7 @@ 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);