]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: fix down_time report for stats
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 29 Oct 2020 14:59:05 +0000 (15:59 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 29 Oct 2020 17:52:39 +0000 (18:52 +0100)
Adjust condition used to report down_time for statistics. There was a
tiny probabilty to have a negative downtime if last_change was superior
to now. If this is the case, return only down_time.

This bug can backported up to 1.8.

src/server.c

index c757cdd36df1b8237971c178c684f3e76d898c63..5ea6ca12c6f7280c552f680b5442e1a265c05e78 100644 (file)
@@ -74,7 +74,7 @@ struct eb_root state_file = EB_ROOT_UNIQUE;
 
 int srv_downtime(const struct server *s)
 {
-       if ((s->cur_state != SRV_ST_STOPPED) && s->last_change < now.tv_sec)            // ignore negative time
+       if ((s->cur_state != SRV_ST_STOPPED) || s->last_change >= now.tv_sec)           // ignore negative time
                return s->down_time;
 
        return now.tv_sec - s->last_change + s->down_time;