Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug ngx_http_upstream_fair_sched_score function.

In SCHED_SCORE(nreq,delta) (((nreq) << SCHED_COUNTER_BITS) | (~(delta))) the ~(delta) would dominate the "bitwise or", making the calculated score ignore the number of requests the peer is currently processing.

The fix is to perform a bitwise mask on ~(delta) so it only affect the lower 20bits.
SCHED_SCORE(nreq,delta) (((nreq) << SCHED_COUNTER_BITS) | (~(delta) & SCHED_COUNTER_MAX))
  • Loading branch information...
commit 2b0837a3f3c8fbc95cac911ad9425b4a744255b3 1 parent 2131c73
root authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  ngx_http_upstream_fair_module.c
View
2  ngx_http_upstream_fair_module.c
@@ -679,7 +679,7 @@ ngx_http_upstream_fair_update_nreq(ngx_http_upstream_fair_peer_data_t *fp, int d
#define SCHED_COUNTER_BITS 20
#define SCHED_NREQ_MAX ((~0UL) >> SCHED_COUNTER_BITS)
#define SCHED_COUNTER_MAX ((1 << SCHED_COUNTER_BITS) - 1)
-#define SCHED_SCORE(nreq,delta) (((nreq) << SCHED_COUNTER_BITS) | (~(delta)))
+#define SCHED_SCORE(nreq,delta) (((nreq) << SCHED_COUNTER_BITS) | (~(delta) & SCHED_COUNTER_MAX))
#define ngx_upstream_fair_min(a,b) (((a) < (b)) ? (a) : (b))
static ngx_uint_t
Please sign in to comment.
Something went wrong with that request. Please try again.