From: Amos Jeffries Date: Wed, 20 Jul 2011 07:04:54 +0000 (+1200) Subject: Bug 2051: 'default' cache_peer option does not match documentation X-Git-Tag: take08~55^2~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4ab8666e50be52f0e99c83e66281d0fdab01193;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 the selection code around #if..#endif once default is moved. Also, getAnyParent() is dropped. It is redundant with the FIRSTUP algorithm. --- diff --git a/src/neighbors.cc b/src/neighbors.cc index eaea4f5f18..398ad00141 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -476,33 +476,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 ea8255bb4b..0c512c0d23 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -594,14 +594,12 @@ peerGetSomeParent(ps_state * ps) if (ps->direct == DIRECT_YES) return; - if ((p = getDefaultParent(request))) { - code = DEFAULT_PARENT; + if ((p = peerSourceHashSelectParent(request))) { + code = SOURCEHASH_PARENT; #if USE_AUTH } else if ((p = peerUserHashSelectParent(request))) { code = USERHASH_PARENT; #endif - } else if ((p = peerSourceHashSelectParent(request))) { - code = SOURCEHASH_PARENT; } else if ((p = carpSelectParent(request))) { code = CARP; } else if ((p = getRoundRobinParent(request))) { @@ -610,8 +608,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 854d7d765c..9b49041631 100644 --- a/src/protos.h +++ b/src/protos.h @@ -360,7 +360,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);