MINOR: proxy: Store monitor_uri as a `struct ist`
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.
diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h
index 421f900..13e722f 100644
--- a/include/haproxy/proxy-t.h
+++ b/include/haproxy/proxy-t.h
@@ -322,8 +322,7 @@
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 5deec5e..eb58b2eb 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -575,13 +575,10 @@
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 f33eb77..b60927e 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -203,9 +203,8 @@
* 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 dbcab47..79aa3f4 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -156,7 +156,7 @@
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);
@@ -1274,7 +1274,7 @@
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);
}
@@ -1436,7 +1436,7 @@
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;
@@ -1711,9 +1711,8 @@
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);