]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Mike Mitchell <Mike.Mitchell@sas.com>
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 13 Jun 2008 10:20:46 +0000 (04:20 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 13 Jun 2008 10:20:46 +0000 (04:20 -0600)
Bug #2241: weights not applied properly in round-robin peer selection

src/neighbors.cc

index 63e94a6cec69baff3bc0b029d3724a4cad2d7ae9..a0ade0e3843c6795aff210d4d60ab39ee5c5ee04 100644 (file)
@@ -315,11 +315,16 @@ getRoundRobinParent(HttpRequest * request)
         if (!peerHTTPOkay(p, request))
             continue;
 
-        if (p->weight == 1) {
-            if (q && q->rr_count < p->rr_count)
-                continue;
-        } else if (p->weight == 0 || (q && q->rr_count < (p->rr_count / p->weight))) {
+        if (p->weight == 0)
             continue;
+
+        if (q) {
+            if (p->weight == q->weight) {
+                if (q->rr_count < p->rr_count)
+                    continue;
+            } else if ( (double) q->rr_count / q->weight < (double) p->rr_count / p->weight) {
+                continue;
+            }
         }
 
         q = p;
@@ -328,7 +333,7 @@ getRoundRobinParent(HttpRequest * request)
     if (q)
         q->rr_count++;
 
-    debugs(15, 3, "getRoundRobinParent: returning " << (q ? q->host : "NULL"));
+    debugs(15, 3, HERE << "returning " << (q ? q->host : "NULL"));
 
     return q;
 }