From: Amos Jeffries Date: Fri, 22 Jul 2011 14:39:54 +0000 (-0600) Subject: Bug 2051: 'default' cache_peer option does not match documentation X-Git-Tag: SQUID_3_1_15~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a59f3ff2f50f929eb8f68dadd8de479692621479;p=thirdparty%2Fsquid.git Bug 2051: 'default' cache_peer option does not match documentation Move the default parent to second-lowest priority on the parent selection. This also allows the other more delicate balancing algorithms to work properly with a default configured. sourcehash and userhash are reversed in priority to simplify and speed the selection code. Also, getAnyParent() is dropped. It is redundant with the FIRSTUP algorithm. --- diff --git a/src/neighbors.cc b/src/neighbors.cc index d5a699285d..72fc635492 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -477,33 +477,6 @@ getDefaultParent(HttpRequest * request) return NULL; } -/* - * XXX DW thinks this function is equivalent to/redundant with - * getFirstUpParent(). peerHTTPOkay() only returns true if the - * peer is UP anyway, so this function would not return a - * DOWN parent. - */ -peer * -getAnyParent(HttpRequest * request) -{ - peer *p = NULL; - - for (p = Config.peers; p; p = p->next) { - if (neighborType(p, request) != PEER_PARENT) - continue; - - if (!peerHTTPOkay(p, request)) - continue; - - debugs(15, 3, "getAnyParent: returning " << p->host); - - return p; - } - - debugs(15, 3, "getAnyParent: returning NULL"); - return NULL; -} - peer * getNextPeer(peer * p) { diff --git a/src/peer_select.cc b/src/peer_select.cc index 13e9b20029..5d9b0bb4a6 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -540,12 +540,10 @@ peerGetSomeParent(ps_state * ps) if (ps->direct == DIRECT_YES) return; - if ((p = getDefaultParent(request))) { - code = DEFAULT_PARENT; + if ((p = peerSourceHashSelectParent(request))) { + code = SOURCEHASH_PARENT; } else if ((p = peerUserHashSelectParent(request))) { code = USERHASH_PARENT; - } else if ((p = peerSourceHashSelectParent(request))) { - code = SOURCEHASH_PARENT; } else if ((p = carpSelectParent(request))) { code = CARP; } else if ((p = getRoundRobinParent(request))) { @@ -554,8 +552,8 @@ peerGetSomeParent(ps_state * ps) code = ROUNDROBIN_PARENT; } else if ((p = getFirstUpParent(request))) { code = FIRSTUP_PARENT; - } else if ((p = getAnyParent(request))) { - code = ANY_OLD_PARENT; + } else if ((p = getDefaultParent(request))) { + code = DEFAULT_PARENT; } if (code != HIER_NONE) { diff --git a/src/protos.h b/src/protos.h index 5a2e8ecdc8..ab7d401801 100644 --- a/src/protos.h +++ b/src/protos.h @@ -388,7 +388,6 @@ SQUIDCEXTERN peer *getRoundRobinParent(HttpRequest * request); SQUIDCEXTERN peer *getWeightedRoundRobinParent(HttpRequest * request); SQUIDCEXTERN void peerClearRRStart(void); SQUIDCEXTERN void peerClearRR(void); -SQUIDCEXTERN peer *getAnyParent(HttpRequest * request); SQUIDCEXTERN lookup_t peerDigestLookup(peer * p, HttpRequest * request); SQUIDCEXTERN peer *neighborsDigestSelect(HttpRequest * request); SQUIDCEXTERN void peerNoteDigestLookup(HttpRequest * request, peer * p, lookup_t lookup);