The monitor_uri is already processed as an ist in `http_wait_for_request`, lets
also just store it as such.

see 0643b0e7e ("MINOR: proxy: Make `header_unique_id` a `struct ist`") for a
very similar past commit.
---
 include/haproxy/proxy-t.h |  3 +--
 src/cfgparse-listen.c     |  9 +++------
 src/http_ana.c            |  5 ++---
 src/proxy.c               | 11 +++++------
 4 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h
index 421f900e2..13e722fbf 100644
--- a/include/haproxy/proxy-t.h
+++ b/include/haproxy/proxy-t.h
@@ -322,8 +322,7 @@ struct proxy {
        int srvtcpka_cnt;                       /* The maximum number of 
keepalive probes TCP should send before dropping the connection. (server side) 
*/
        int srvtcpka_idle;                      /* The time (in seconds) the 
connection needs to remain idle before TCP starts sending keepalive probes. 
(server side) */
        int srvtcpka_intvl;                     /* The time (in seconds) 
between individual keepalive probes. (server side) */
-       int monitor_uri_len;                    /* length of the string above. 
0 if unused */
-       char *monitor_uri;                      /* a special URI to which we 
respond with HTTP/200 OK */
+       struct ist monitor_uri;                 /* a special URI to which we 
respond with HTTP/200 OK */
        struct list mon_fail_cond;              /* list of conditions to fail 
monitoring requests (chained) */
        struct {                                /* WARNING! check 
proxy_reset_timeouts() in proxy.h !!! */
                int client;                     /* client I/O timeout (in 
ticks) */
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index 5deec5e6b..eb58b2eb1 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -575,13 +575,10 @@ int cfg_parse_listen(const char *file, int linenum, char 
**args, int kwm)
                        goto out;
                }
 
-               free(curproxy->monitor_uri);
-               curproxy->monitor_uri_len = strlen(args[1]);
-               curproxy->monitor_uri = calloc(1, curproxy->monitor_uri_len + 
1);
-               if (!curproxy->monitor_uri)
+               istfree(&curproxy->monitor_uri);
+               curproxy->monitor_uri = istdup(ist(args[1]));
+               if (!isttest(curproxy->monitor_uri))
                        goto alloc_error;
-               memcpy(curproxy->monitor_uri, args[1], 
curproxy->monitor_uri_len);
-               curproxy->monitor_uri[curproxy->monitor_uri_len] = '\0';
 
                goto out;
        }
diff --git a/src/http_ana.c b/src/http_ana.c
index f33eb7790..b60927e52 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -203,9 +203,8 @@ int http_wait_for_request(struct stream *s, struct channel 
*req, int an_bit)
         * used. It is a workaround to let HTTP/2 health-checks work as
         * expected.
         */
-       if (unlikely(sess->fe->monitor_uri_len != 0)) {
-               const struct ist monitor_uri = ist2(sess->fe->monitor_uri,
-                                                   sess->fe->monitor_uri_len);
+       if (unlikely(isttest(sess->fe->monitor_uri))) {
+               const struct ist monitor_uri = sess->fe->monitor_uri;
                struct http_uri_parser parser = 
http_uri_parser_init(htx_sl_req_uri(sl));
 
                if ((istptr(monitor_uri)[0] == '/' &&
diff --git a/src/proxy.c b/src/proxy.c
index 946fe13d5..e5cf81327 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -156,7 +156,7 @@ void free_proxy(struct proxy *p)
        free(p->lbprm.arg_str);
        free(p->server_state_file_name);
        free(p->capture_name);
-       free(p->monitor_uri);
+       istfree(&p->monitor_uri);
        free(p->rdp_cookie_name);
        free(p->invalid_rep);
        free(p->invalid_req);
@@ -1270,7 +1270,7 @@ int proxy_cfg_ensure_no_http(struct proxy *curproxy)
                ha_warning("cookie will be ignored for %s '%s' (needs 'mode 
http').\n",
                           proxy_type_str(curproxy), curproxy->id);
        }
-       if (curproxy->monitor_uri != NULL) {
+       if (isttest(curproxy->monitor_uri)) {
                ha_warning("monitor-uri will be ignored for %s '%s' (needs 
'mode http').\n",
                           proxy_type_str(curproxy), curproxy->id);
        }
@@ -1432,7 +1432,7 @@ void proxy_free_defaults(struct proxy *defproxy)
        ha_free(&defproxy->cookie_attrs);
        ha_free(&defproxy->lbprm.arg_str);
        ha_free(&defproxy->capture_name);
-       ha_free(&defproxy->monitor_uri);
+       istfree(&defproxy->monitor_uri);
        ha_free(&defproxy->defbe.name);
        ha_free(&defproxy->conn_src.iface_name);
        ha_free(&defproxy->fwdfor_hdr_name); defproxy->fwdfor_hdr_len = 0;
@@ -1707,9 +1707,8 @@ static int proxy_defproxy_cpy(struct proxy *curproxy, 
const struct proxy *defpro
                curproxy->timeout.tarpit = defproxy->timeout.tarpit;
                curproxy->timeout.httpreq = defproxy->timeout.httpreq;
                curproxy->timeout.httpka = defproxy->timeout.httpka;
-               if (defproxy->monitor_uri)
-                       curproxy->monitor_uri = strdup(defproxy->monitor_uri);
-               curproxy->monitor_uri_len = defproxy->monitor_uri_len;
+               if (isttest(defproxy->monitor_uri))
+                       curproxy->monitor_uri = istdup(defproxy->monitor_uri);
                if (defproxy->defbe.name)
                        curproxy->defbe.name = strdup(defproxy->defbe.name);
 
-- 
2.35.1


Reply via email to