From: Frederic Lecaille Date: Mon, 31 Aug 2026 08:20:18 +0000 (+0200) Subject: MINOR: haload: rename to X-Git-Tag: v3.5-dev6~30 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=40bc3917dc9f837d036c94a6bfd5bf47175f81e6;p=haproxy.git MINOR: haload: rename to Not only an HTTP version, it's an index for the stats. Renamed before adding a non-HTTP protocol (FCGI) to it. --- diff --git a/include/haproxy/haload.h b/include/haproxy/haload.h index 952ec6659..5983d31f7 100644 --- a/include/haproxy/haload.h +++ b/include/haproxy/haload.h @@ -7,18 +7,18 @@ #include #include -#define HLD_HAS_HTTP_VER_0 (1U << HLD_HTTP_VER_0) -#define HLD_HAS_HTTP_VER_1 (1U << HLD_HTTP_VER_1) -#define HLD_HAS_HTTP_VER_2 (1U << HLD_HTTP_VER_2) -#define HLD_HAS_HTTP_VER_3 (1U << HLD_HTTP_VER_3) +#define HLD_HAS_PROTO_H0 (1U << HLD_PROTO_H0) +#define HLD_HAS_PROTO_H1 (1U << HLD_PROTO_H1) +#define HLD_HAS_PROTO_H2 (1U << HLD_PROTO_H2) +#define HLD_HAS_PROTO_H3 (1U << HLD_PROTO_H3) -enum hld_http_ver { - HLD_HTTP_VER_0, - HLD_HTTP_VER_1, - HLD_HTTP_VER_2, - HLD_HTTP_VER_3, +enum hld_proto { + HLD_PROTO_H0, + HLD_PROTO_H1, + HLD_PROTO_H2, + HLD_PROTO_H3, /* Do not add more enum below */ - HLD_HTTP_VER_MAX, + HLD_PROTO_MAX, }; @@ -35,7 +35,7 @@ struct hld_url_cfg { int is_quic; int h2c; int thnk_time; - enum hld_http_ver http_ver; + enum hld_proto proto; char *addr; char *raw_addr; // used only to set the host header value char *srv_opts; @@ -89,5 +89,5 @@ extern int arg_thnk; extern int arg_thrd; extern int arg_wait; -extern unsigned int hld_ver_flags; +extern unsigned int hld_proto_flags; #endif /* _HAPROXY_HALOAD_H */ diff --git a/src/haload.c b/src/haload.c index 7521129af..99194ab6f 100644 --- a/src/haload.c +++ b/src/haload.c @@ -66,7 +66,7 @@ struct hld_thr_info { uint64_t *ttfb_pct; // counts per ttfb value for percentile uint64_t *ttlb_pct; // counts per ttlb value for percentile uint64_t tot_sc[5]; // total status codes on this thread: 1xx,2xx,3xx,4xx,5xx - uint64_t vtot_sc[HLD_HTTP_VER_MAX][5]; // by version total status codes + uint64_t vtot_sc[HLD_PROTO_MAX][5]; // by protocol total status codes // on this thread: 1xx,2xx,3xx,4xx,5xx struct task *rate_task; // task used when is set __attribute__((aligned(64))) union { } __pad; @@ -128,7 +128,7 @@ int all_usr_stop_asap; // all users must stop as soon as possible int usr_tid; int usr_cnt; // user counter incremented by main task int running_tasks; // tasks counter for the users and for the conn rate -unsigned int hld_ver_flags; // flags to identify the HTTP versions used +unsigned int hld_proto_flags; // flags to identify the protocols used char *hld_args[MAX_LINE_ARGS + 1]; @@ -664,7 +664,7 @@ static void hld_reset_counters(void) if (arg_hscd == 2) { int v, i; - for (v = HLD_HTTP_VER_0; v < HLD_HTTP_VER_MAX; v++) + for (v = HLD_PROTO_H0; v < HLD_PROTO_MAX; v++) for (i = 0; i < 5; i++) HA_ATOMIC_STORE(&thrs_info[th].vtot_sc[v][i], 0); } @@ -677,10 +677,10 @@ void hld_summary(void) { int th; uint64_t cur_conn, tot_conn, tot_req, tot_err, tot_rcvd, bytes; - uint64_t tot_ttfb, tot_ttlb, tot_fbs, tot_lbs, tot_sc[5], vtot_sc[HLD_HTTP_VER_MAX][5]; + uint64_t tot_ttfb, tot_ttlb, tot_fbs, tot_lbs, tot_sc[5], vtot_sc[HLD_PROTO_MAX][5]; static uint64_t prev_totc, prev_totr, prev_totb; static uint64_t prev_ttfb, prev_ttlb, prev_fbs, prev_lbs, prev_sc[5], - prev_vsc[HLD_HTTP_VER_MAX][5]; + prev_vsc[HLD_PROTO_MAX][5]; static struct timeval prev_date = TV_UNSET; double interval; @@ -692,7 +692,7 @@ void hld_summary(void) if (arg_hscd == 2) { int v; - for (v = HLD_HTTP_VER_0; v < HLD_HTTP_VER_MAX; v++) + for (v = HLD_PROTO_H0; v < HLD_PROTO_MAX; v++) prev_vsc[v][0] = prev_vsc[v][1] = prev_vsc[v][2] = prev_vsc[v][3] = prev_vsc[v][4] = 0; } prev_date = TV_UNSET; @@ -706,7 +706,7 @@ void hld_summary(void) if (arg_hscd == 2) { int v; - for (v = HLD_HTTP_VER_0; v < HLD_HTTP_VER_MAX; v++) + for (v = HLD_PROTO_H0; v < HLD_PROTO_MAX; v++) vtot_sc[v][0] = vtot_sc[v][1] = vtot_sc[v][2] = vtot_sc[v][3] = vtot_sc[v][4] = 0; } @@ -730,8 +730,8 @@ void hld_summary(void) if (arg_hscd == 2) { int v; - for (v = HLD_HTTP_VER_0; v < HLD_HTTP_VER_MAX; v++) { - if (!(hld_ver_flags & (1U << v))) + for (v = HLD_PROTO_H0; v < HLD_PROTO_MAX; v++) { + if (!(hld_proto_flags & (1U << v))) continue; vtot_sc[v][0]+= HA_ATOMIC_LOAD(&thrs_info[th].vtot_sc[v][0]); @@ -815,8 +815,8 @@ void hld_summary(void) if (arg_hscd == 2) { int v; - for (v = HLD_HTTP_VER_0; v < HLD_HTTP_VER_MAX; v++) { - if (!(hld_ver_flags & (1U << v))) + for (v = HLD_PROTO_H0; v < HLD_PROTO_MAX; v++) { + if (!(hld_proto_flags & (1U << v))) continue; printf(" %3llu %3llu %3llu %3llu %3llu", @@ -849,7 +849,7 @@ void hld_summary(void) if (arg_hscd == 2) { int v; - for (v = HLD_HTTP_VER_0; v < HLD_HTTP_VER_MAX; v++) { + for (v = HLD_PROTO_H0; v < HLD_PROTO_MAX; v++) { prev_vsc[v][0] = vtot_sc[v][0]; prev_vsc[v][1] = vtot_sc[v][1]; prev_vsc[v][2] = vtot_sc[v][2]; @@ -1027,7 +1027,7 @@ static struct task *mtask_cb(struct task *t, void *context, unsigned int state) int i; for (i = 0 ; i < 4; i++) { - if (!(hld_ver_flags & (1 << i))) + if (!(hld_proto_flags & (1 << i))) continue; printf(" (h%d)1xx 2xx 3xx 4xx 5xx", i); } @@ -1427,7 +1427,7 @@ static void hldstream_htx_buf_rcv(struct connection *conn, if (arg_hscd) thrs_info[tid].tot_sc[status * 41 / 4096 - 1]++; if (arg_hscd == 2) { - thrs_info[tid].vtot_sc[hs->url->cfg->http_ver][status * 41 / 4096 - 1]++; + thrs_info[tid].vtot_sc[hs->url->cfg->proto][status * 41 / 4096 - 1]++; } if (hs->url->tot_req > 1 || !arg_accu) { ttfb = tv_us(tv_diff(&hs->req_date, &date)); diff --git a/src/haload_init.c b/src/haload_init.c index 5e86e3fac..d0dc565e1 100644 --- a/src/haload_init.c +++ b/src/haload_init.c @@ -195,7 +195,7 @@ int hld_url_cfg_path_exist(struct hld_url_cfg *u, const char *path) */ static struct hld_url_cfg *hld_alloc_url(char *url, int is_quic, char *alpn_param, int h2c_param, - enum hld_http_ver http_ver) + enum hld_proto proto) { int ssl = 0; char *addr = NULL, *raw_addr = NULL, *path = NULL; @@ -308,7 +308,7 @@ static struct hld_url_cfg *hld_alloc_url(char *url, int is_quic, hld_url_cfg->is_quic = is_quic; hld_url_cfg->h2c = h2c_param; hld_url_cfg->thnk_time = arg_thnk; - hld_url_cfg->http_ver = http_ver; + hld_url_cfg->proto = proto; hld_url_cfg->addr = addr; hld_url_cfg->raw_addr = raw_addr; if (alpn_param) { @@ -416,7 +416,7 @@ void haproxy_init_args(int argc, char **argv) struct hbuf gbuf = HBUF_NULL; // "global" section struct hbuf tbuf = HBUF_NULL; // "traces" section struct hbuf dbuf = HBUF_NULL; // "default" section - int http_ver = HLD_HTTP_VER_1; + int proto = HLD_PROTO_H1; if (argc <= 1) hld_usage(progname, argc); @@ -522,32 +522,32 @@ void haproxy_init_args(int argc, char **argv) strcmp(opt, "h0") == 0) { alpn = "hq-interop"; h2c = 0; - http_ver = HLD_HTTP_VER_0; + proto = HLD_PROTO_H0; } else if (strcmp(opt, "1") == 0 || strcmp(opt, "h1") == 0) { alpn = "http/1.1"; h2c = 0; - http_ver = HLD_HTTP_VER_1; + proto = HLD_PROTO_H1; } else if (strcmp(opt, "2") == 0 || strcmp(opt, "h2") == 0) { alpn = "h2"; h2c = 0; - http_ver = HLD_HTTP_VER_2; + proto = HLD_PROTO_H2; } else if (strcmp(opt, "2c") == 0 || strcmp(opt, "h2c") == 0) { alpn = NULL; h2c = 1; - http_ver = HLD_HTTP_VER_2; + proto = HLD_PROTO_H2; } else if (strcmp(opt, "3") == 0 || strcmp(opt, "h3") == 0) { #if defined(USE_QUIC) alpn = "h3"; h2c = 0; - http_ver = HLD_HTTP_VER_3; + proto = HLD_PROTO_H3; #else ha_warning("QUIC support not compiled in. Rebuild with USE_QUIC=1.\n"); goto leave; @@ -707,18 +707,18 @@ void haproxy_init_args(int argc, char **argv) is_quic = strncmp(*argv, "quic://", 7) == 0; if (is_quic) - http_ver = HLD_HTTP_VER_3; - hld_ver_flags |= (1 << http_ver); + proto = HLD_PROTO_H3; + hld_proto_flags |= (1 << proto); url = hld_alloc_url(*argv, is_quic, is_quic ? "h3" : alpn, - is_quic ? 0 : h2c, http_ver); + is_quic ? 0 : h2c, proto); if (!url) { ha_alert("could not parse a new URL\n"); goto leave; } /* default version flag value */ - http_ver = HLD_HTTP_VER_3; + proto = HLD_PROTO_H3; } argv++; argc--;