From: Amaury Denoyelle Date: Thu, 29 Oct 2020 14:59:04 +0000 (+0100) Subject: BUG/MINOR: server: fix srv downtime calcul on starting X-Git-Tag: v2.1.10~14 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=fa74247fea0998dd531ae092dd3da101f85dfdcb;p=haproxy-2.1.git BUG/MINOR: server: fix srv downtime calcul on starting When a server is up after a failure, its downtime was reset to 0 on the statistics. This is due to a wrong condition that causes srv.down_time to never be set. Fix this by updating down_time each time the server is in STARTING state. Fixes the github issue #920. This bug can be backported up to 1.8. (cherry picked from commit fe2bf091f6f2c155b5d7b1372a43b73bb034002f) Signed-off-by: Christopher Faulet (cherry picked from commit 774d5a3b69bf8c588c26ce09a6acbf29997a82ac) Signed-off-by: Christopher Faulet --- diff --git a/src/server.c b/src/server.c index b19e351..ab03fd3 100644 --- a/src/server.c +++ b/src/server.c @@ -4996,7 +4996,7 @@ static void srv_update_status(struct server *s) s->proxy->last_change = now.tv_sec; } - if (s->next_state == SRV_ST_STOPPED && s->last_change < now.tv_sec) // ignore negative times + if (s->cur_state == SRV_ST_STOPPED && s->last_change < now.tv_sec) // ignore negative times s->down_time += now.tv_sec - s->last_change; s->last_change = now.tv_sec;