From: Amos Jeffries Date: Wed, 9 Jun 2010 10:44:03 +0000 (+1200) Subject: Enforce forward_max_tries configuration option X-Git-Tag: take08~55^2~124^2~131 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=27d1f0a0c78a29fe731c2b274ddd0f0c614e6dff;p=thirdparty%2Fsquid.git Enforce forward_max_tries configuration option --- diff --git a/src/comm/Connection.h b/src/comm/Connection.h index 76da31315a..e8f587b005 100644 --- a/src/comm/Connection.h +++ b/src/comm/Connection.h @@ -45,8 +45,10 @@ struct peer; namespace Comm { -/** COMM flags */ -/* TODO: make these a struct of boolean flags in connection instead of a bitmap. */ +/* TODO: make these a struct of boolean flags members in the connection instead of a bitmap. + * we can't do that until all non-comm code uses Commm::Connection objects to create FD + * currently there is code still using comm_open() and comm_openex() synchronously!! + */ #define COMM_UNSET 0x00 #define COMM_NONBLOCKING 0x01 #define COMM_NOCLOEXEC 0x02 diff --git a/src/peer_select.cc b/src/peer_select.cc index b4088c8d35..6d0d7d06ca 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -214,11 +214,8 @@ peerSelectDnsPaths(ps_state *psstate) { FwdServer *fs = psstate->servers; - // TODO enforce Config.forward_max_tries and/or Config.retry.maxtries - // the maximum number of paths we are allowed to try... - // convert the list of FwdServer destinations into destinations IP addresses - if (fs) { + if (fs && psstate->paths->size() < Config.forward_max_tries) { // send the next one off for DNS lookup. const char *host = fs->_peer ? fs->_peer->host : psstate->request->GetHost(); debugs(44, 2, "Find IP destination for: " << psstate->entry->url() << "' via " << host); @@ -258,6 +255,10 @@ peerSelectDnsResults(const ipcache_addrs *ia, const DnsLookupDetails &details, v for (int n = 0; n < ia->count; n++, ip++) { if (ip >= ia->count) ip = 0; // looped back to zero. + // Enforce forward_max_tries configuration. + if (psstate->paths->paths() >= Config.forward_max_tries) + break; + // for TPROXY we must skip unusable addresses. if (psstate->request->flags.spoof_client_ip && !(fs->_peer && fs->_peer->options.no_tproxy) ) { if(ia->in_addrs[n].IsIPv4() != psstate->request->client_addr.IsIPv4()) { @@ -424,7 +425,6 @@ peerSelectFoo(ps_state * ps) // resolve the possible peers peerSelectDnsPaths(ps); -// DEAD? peerSelectCallback(ps); } int peerAllowedToUse(const peer * p, HttpRequest * request);