[MEDIUM] slowstart: ensure we don't start with a null weight

Because of a divide, it was possible to have a null weight during
a slowstart, which is pretty annoying, especially with a single
server and a long slowstart.

Also, fix the way we report the values in the stats page to avoid
confusion.
This commit is contained in:
Willy Tarreau 2007-12-03 02:04:00 +01:00
parent 3259e3369e
commit 5542af65dc
2 changed files with 6 additions and 5 deletions

View file

@ -540,7 +540,8 @@ void process_chk(struct task *t, struct timeval *next)
}
else if (s->proxy->lbprm.algo & BE_LB_PROP_DYN) {
/* for dynamic algorithms, let's update the weight */
s->eweight = BE_WEIGHT_SCALE * (now.tv_sec - s->last_change) / s->slowstart;
s->eweight = (BE_WEIGHT_SCALE * (now.tv_sec - s->last_change) +
s->slowstart - 1) / s->slowstart;
s->eweight *= s->uweight;
if (s->proxy->lbprm.update_server_eweight)
s->proxy->lbprm.update_server_eweight(s);

View file

@ -767,7 +767,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
/* act, bck */
"<td>%s</td><td>%s</td>"
"",
sv->eweight * px->lbprm.wmult / px->lbprm.wdiv,
(sv->eweight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv,
(sv->state & SRV_BACKUP) ? "-" : "Y",
(sv->state & SRV_BACKUP) ? "Y" : "-");
@ -834,7 +834,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
/* weight, active, backup */
"%d,%d,%d,"
"",
sv->eweight * px->lbprm.wmult / px->lbprm.wdiv,
(sv->eweight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv,
(sv->state & SRV_BACKUP) ? 0 : 1,
(sv->state & SRV_BACKUP) ? 1 : 0);
@ -910,7 +910,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
human_time(now.tv_sec - px->last_change, 1),
(px->lbprm.tot_weight > 0 || !px->srv) ? "UP" :
"<font color=\"red\"><b>DOWN</b></font>",
px->lbprm.tot_weight * px->lbprm.wmult / px->lbprm.wdiv,
(px->lbprm.tot_weight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv,
px->srv_act, px->srv_bck);
chunk_printf(&msg, sizeof(trash),
@ -956,7 +956,7 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri,
px->failed_conns, px->failed_resp,
px->retries, px->redispatches,
(px->lbprm.tot_weight > 0 || !px->srv) ? "UP" : "DOWN",
px->lbprm.tot_weight * px->lbprm.wmult / px->lbprm.wdiv,
(px->lbprm.tot_weight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv,
px->srv_act, px->srv_bck,
px->down_trans, now.tv_sec - px->last_change,
px->srv?be_downtime(px):0,