]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Enforce forward_max_tries configuration option
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 9 Jun 2010 10:44:03 +0000 (22:44 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 9 Jun 2010 10:44:03 +0000 (22:44 +1200)
src/comm/Connection.h
src/peer_select.cc

index 76da31315aa3f9517cc6abf0d871e476e4a3be92..e8f587b0050f5c6a78028e8b21c5e14338ef1e7d 100644 (file)
@@ -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
index b4088c8d3550c5b9a556a96bf36c996239ded1a7..6d0d7d06ca4aa3e41f6d4ef88505a42b8c2d47ae 100644 (file)
@@ -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);