Permalink
Browse files

Fix division by zero while calculating scheduler score

Reported by Eric Wong
  • Loading branch information...
gnosek committed Nov 29, 2007
1 parent 8d3be7e commit d4af0bbaa3f0354e900e295131fd97a023b83979
Showing with 6 additions and 4 deletions.
  1. +6 −4 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);

0 comments on commit d4af0bb

Please sign in to comment.