gnosek/nginx-upstream-fair — pull request #2 by qualtrics (2011-10-27 15:52:56+00:00)
Title: 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))