]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: always merge the uri_auth flags into the appctx flags
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Oct 2019 08:50:01 +0000 (10:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Oct 2019 09:30:07 +0000 (11:30 +0200)
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.

src/http_ana.c
src/stats.c

index 70956579fd619d9b8f8a33a724d6c8fbcd5b7ece..f1546fdd720e7766e95777ac0a0f292ef84cc71e 100644 (file)
@@ -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;
index 14e5e7c3075184c254db369528079825cf9e120e..7063ad0f05e93caf0b25cc25e1d1baa47dc4e77b 100644 (file)
@@ -1949,7 +1949,7 @@ static int stats_dump_be_stats(struct stream_interface *si, struct proxy *px, in
  * stream interface <si> and per-uri parameters <uri>. 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
                      "<a name=\"%s\"></a>%s"
                      "<a class=px href=\"#%s\">%s</a>",
                      px->id,
-                     (uri->flags & STAT_SHLGNDS) ? "<u>":"",
+                     (appctx->ctx.stats.flags & STAT_SHLGNDS) ? "<u>":"",
                      px->id, px->id);
 
-       if (uri->flags & STAT_SHLGNDS) {
+       if (appctx->ctx.stats.flags & STAT_SHLGNDS) {
                /* cap, mode, id */
                chunk_appendf(&trash, "<div class=tips>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
                      "</table>\n"
                      "<table class=\"tbl\" width=\"100%%\">\n"
                      "<tr class=\"titre\">",
-                     (uri->flags & STAT_SHLGNDS) ? "</u>":"",
+                     (appctx->ctx.stats.flags & STAT_SHLGNDS) ? "</u>":"",
                      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 <uri>. 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"
                      "</style></head>\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
                      "<td align=\"left\" valign=\"top\" nowrap width=\"1%%\">"
                      "<b>Display option:</b><ul style=\"margin-top: 0.25em;\">"
                      "",
-                     (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)