Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix division by zero while calculating scheduler score

Reported by Eric Wong
  • Loading branch information...
commit d4af0bbaa3f0354e900e295131fd97a023b83979 1 parent 8d3be7e
@gnosek authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 ngx_http_upstream_fair_module.c
View
10 ngx_http_upstream_fair_module.c
@@ -577,10 +577,12 @@ ngx_http_upstream_choose_fair_peer(ngx_peer_connection_t *pc,
/*
* take peer weight into account
*/
- if (sched_score < 0) {
- sched_score /= peer->current_weight;
- } else {
- sched_score *= peer->current_weight;
+ if (peer->current_weight > 0) {
+ if (sched_score < 0) {
+ sched_score /= peer->current_weight;
+ } else {
+ sched_score *= peer->current_weight;
+ }
}
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, pc->log, 0, "[upstream_fair] pss = %i, ss = %i (n = %d)", prev_sched_score, sched_score, n);
Please sign in to comment.
Something went wrong with that request. Please try again.