]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Mike Mitchell <Mike.Mitchell@sas.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 12 Jun 2008 12:49:29 +0000 (00:49 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 12 Jun 2008 12:49:29 +0000 (00:49 +1200)
Bug #2241: weights not applied properly in round-robin peer selection

src/neighbors.cc

index 6fb4e7c07af0f2e7cfe32d89f7bfa4bfa7126ac8..ed318d93d4fe91310baef4c76eafe0e50cd0b251 100644 (file)
@@ -312,11 +312,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;
@@ -325,7 +330,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;
 }