From: hno <> Date: Mon, 14 Jan 2008 19:13:49 +0000 (+0000) Subject: Bug #2153: Use the cache_peer name in CARP hashing to support multiple peers on the... X-Git-Tag: BASIC_TPROXY4~193 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d4140027cb1d6e3d358b99b631e3ae48010afd12;p=thirdparty%2Fsquid.git 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. --- diff --git a/src/carp.cc b/src/carp.cc index 56e95e1b08..9c7fa65324 100644 --- a/src/carp.cc +++ b/src/carp.cc @@ -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);