From 8485f4e43b8b904b224f79044dd42843a89909a9 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 7 Jan 2016 13:59:10 +0100 Subject: [PATCH] MINOR: stats: do not check srv->state for SRV_ST_STOPPED in HTML dumps We don't want the HTML dump to rely on the server state. We already have this piece of information in the status field by checking that it starts with "DOWN". --- src/dumpstats.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dumpstats.c b/src/dumpstats.c index 7cb423d8b..53131ab7d 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -3937,20 +3937,21 @@ static int stats_dump_sv_stats(struct stream_interface *si, struct proxy *px, in if (memcmp(field_str(stats, ST_F_STATUS), "MAINT", 5) == 0) { chunk_appendf(&trash, "%s MAINT", human_time(stats[ST_F_LASTCHG].u.u32, 1)); } - else if ((ref->agent.state & CHK_ST_ENABLED) && !(sv->agent.health) && (ref->state == SRV_ST_STOPPED)) { - chunk_appendf(&trash, "%s ", human_time(stats[ST_F_LASTCHG].u.u32, 1)); + else if (memcmp(field_str(stats, ST_F_STATUS), "DOWN", 4) == 0 && + (ref->agent.state & CHK_ST_ENABLED) && !(sv->agent.health)) { /* DOWN (agent) */ + chunk_appendf(&trash, "%s ", human_time(stats[ST_F_LASTCHG].u.u32, 1)); chunk_appendf(&trash, srv_hlt_st[1], "GCC: your -Werror=format-security is bogus, annoying, and hides real bugs, I don't thank you, really!"); } else if (ref->check.state & CHK_ST_ENABLED) { chunk_appendf(&trash, "%s ", human_time(stats[ST_F_LASTCHG].u.u32, 1)); chunk_appendf(&trash, srv_hlt_st[state], - (ref->state != SRV_ST_STOPPED) ? (ref->check.health - ref->check.rise + 1) : (ref->check.health), - (ref->state != SRV_ST_STOPPED) ? (ref->check.fall) : (ref->check.rise)); + (memcmp(field_str(stats, ST_F_STATUS), "DOWN", 4) == 0) ? ref->check.health : ref->check.health - ref->check.rise + 1, + (memcmp(field_str(stats, ST_F_STATUS), "DOWN", 4) == 0) ? ref->check.rise : ref->check.fall); } - if ((sv->state == SRV_ST_STOPPED) && + if (memcmp(field_str(stats, ST_F_STATUS), "DOWN", 4) == 0 && ((sv->agent.state & (CHK_ST_ENABLED|CHK_ST_PAUSED)) == CHK_ST_ENABLED) && !(sv->agent.health)) { chunk_appendf(&trash, " %s%s",