From: Willy Tarreau Date: Wed, 9 Oct 2019 08:50:01 +0000 (+0200) Subject: MINOR: stats: always merge the uri_auth flags into the appctx flags X-Git-Tag: v2.1-dev3~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=676c29e3ae3505dc3f3817af4ac39a1ba7ecc918;p=thirdparty%2Fhaproxy.git MINOR: stats: always merge the uri_auth flags into the appctx flags Now we only use the appctx flags everywhere in the code, and the uri_auth flags are read only by the HTTP analyser which presets the appctx ones. This will allow to simplify access to the flags everywhere. --- diff --git a/src/http_ana.c b/src/http_ana.c index 70956579fd..f1546fdd72 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -4375,6 +4375,7 @@ static int http_handle_stats(struct stream *s, struct channel *req) memset(&appctx->ctx.stats, 0, sizeof(appctx->ctx.stats)); appctx->st1 = appctx->st2 = 0; appctx->ctx.stats.st_code = STAT_STATUS_INIT; + appctx->ctx.stats.flags |= uri_auth->flags; appctx->ctx.stats.flags |= STAT_FMT_HTML; /* assume HTML mode by default */ if ((msg->flags & HTTP_MSGF_VER_11) && (txn->meth != HTTP_METH_HEAD)) appctx->ctx.stats.flags |= STAT_CHUNKED; diff --git a/src/stats.c b/src/stats.c index 14e5e7c307..7063ad0f05 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1949,7 +1949,7 @@ static int stats_dump_be_stats(struct stream_interface *si, struct proxy *px, in * stream interface and per-uri parameters . The caller is responsible * for clearing the trash if needed. */ -static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px, struct uri_auth *uri) +static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px) { struct appctx *appctx = __objt_appctx(si->end); char scope_txt[STAT_SCOPE_TXT_MAXLEN + sizeof STAT_SCOPE_PATTERN]; @@ -1981,10 +1981,10 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px "%s" "%s", px->id, - (uri->flags & STAT_SHLGNDS) ? "":"", + (appctx->ctx.stats.flags & STAT_SHLGNDS) ? "":"", px->id, px->id); - if (uri->flags & STAT_SHLGNDS) { + if (appctx->ctx.stats.flags & STAT_SHLGNDS) { /* cap, mode, id */ chunk_appendf(&trash, "
cap: %s, mode: %s, id: %d", proxy_cap_str(px->cap), proxy_mode_str(px->mode), @@ -1999,7 +1999,7 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px "\n" "\n" "", - (uri->flags & STAT_SHLGNDS) ? "":"", + (appctx->ctx.stats.flags & STAT_SHLGNDS) ? "":"", px->desc ? "desc" : "empty", px->desc ? px->desc : ""); if ((px->cap & PR_CAP_BE) && px->srv && (appctx->ctx.stats.flags & STAT_ADMIN)) { @@ -2087,7 +2087,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx, unsigned int flags; if (uri) - flags = uri->flags; + flags = appctx->ctx.stats.flags; else if ((strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) >= ACCESS_LVL_OPER) flags = STAT_SHLGNDS | STAT_SHNODE | STAT_SHDESC; else @@ -2142,7 +2142,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx, case STAT_PX_ST_TH: if (appctx->ctx.stats.flags & STAT_FMT_HTML) { - stats_dump_html_px_hdr(si, px, uri); + stats_dump_html_px_hdr(si, px); if (!stats_putchk(rep, htx, &trash)) goto full; } @@ -2277,7 +2277,7 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx, /* Dumps the HTTP stats head block to the trash for and uses the per-uri * parameters . The caller is responsible for clearing the trash if needed. */ -static void stats_dump_html_head(struct uri_auth *uri) +static void stats_dump_html_head(struct appctx *appctx, struct uri_auth *uri) { /* WARNING! This must fit in the first buffer !!! */ chunk_appendf(&trash, @@ -2386,8 +2386,8 @@ static void stats_dump_html_head(struct uri_auth *uri) "u:hover div.tips {visibility:visible;}\n" "-->\n" "\n", - (uri->flags & STAT_SHNODE) ? " on " : "", - (uri->flags & STAT_SHNODE) ? (uri->node ? uri->node : global.node) : "" + (appctx->ctx.stats.flags & STAT_SHNODE) ? " on " : "", + (appctx->ctx.stats.flags & STAT_SHNODE) ? (uri->node ? uri->node : global.node) : "" ); } @@ -2454,11 +2454,11 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u "
" "Display option:
    " "", - (uri->flags & STAT_HIDEVER) ? "" : (stats_version_string), - pid, (uri->flags & STAT_SHNODE) ? " on " : "", - (uri->flags & STAT_SHNODE) ? (uri->node ? uri->node : global.node) : "", - (uri->flags & STAT_SHDESC) ? ": " : "", - (uri->flags & STAT_SHDESC) ? (uri->desc ? uri->desc : global.desc) : "", + (appctx->ctx.stats.flags & STAT_HIDEVER) ? "" : (stats_version_string), + pid, (appctx->ctx.stats.flags & STAT_SHNODE) ? " on " : "", + (appctx->ctx.stats.flags & STAT_SHNODE) ? (uri->node ? uri->node : global.node) : "", + (appctx->ctx.stats.flags & STAT_SHDESC) ? ": " : "", + (appctx->ctx.stats.flags & STAT_SHDESC) ? (uri->desc ? uri->desc : global.desc) : "", pid, relative_pid, global.nbproc, global.nbthread, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60), @@ -2695,7 +2695,7 @@ static int stats_dump_stat_to_buffer(struct stream_interface *si, struct htx *ht case STAT_ST_HEAD: if (appctx->ctx.stats.flags & STAT_FMT_HTML) - stats_dump_html_head(uri); + stats_dump_html_head(appctx, uri); else if (appctx->ctx.stats.flags & STAT_JSON_SCHM) stats_dump_json_schema(&trash); else if (appctx->ctx.stats.flags & STAT_FMT_JSON)