From: Amos Jeffries Date: Thu, 12 Jun 2008 12:49:29 +0000 (+1200) Subject: Author: Mike Mitchell X-Git-Tag: SQUID_3_1_0_1~49^2~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d0bef67e07a761dec66b40d1be10ce7c213347d;p=thirdparty%2Fsquid.git Author: Mike Mitchell Bug #2241: weights not applied properly in round-robin peer selection --- diff --git a/src/neighbors.cc b/src/neighbors.cc index 6fb4e7c07a..ed318d93d4 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -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; }