From: Christopher Faulet Date: Tue, 15 Sep 2026 11:58:16 +0000 (+0200) Subject: MINOR: htx: Rename htx_has_eom() into htx_msg_ended() X-Git-Tag: v3.5-dev8~152 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=cb50ed3012ee2b0801813ccd0e758952037063fe;p=haproxy.git MINOR: htx: Rename htx_has_eom() into htx_msg_ended() htx_has_eom() name suggests the HTX message contains a block carrying the HTX_BLK_FL_EOM flag. It is true for now, because the flag can only be found on the tail block. But this will change. The block carrying this flag may be consumed while the end of the message must still be reported. So the name is misleading and htx_msg_ended() is more accurate: it states the end of the message was reached, regardless of the presence of the flag in the message. Only a rename, there is no change of behavior. Note the sample fetch "internal.htx.has_eom" was not renamed because it is part of the configuration. --- diff --git a/include/haproxy/htx.h b/include/haproxy/htx.h index 234dfc587..14f4e3c86 100644 --- a/include/haproxy/htx.h +++ b/include/haproxy/htx.h @@ -263,11 +263,11 @@ static inline enum htx_blk_type htx_get_tail_type(const struct htx *htx) return (blk ? htx_get_blk_type(blk) : HTX_BLK_UNUSED); } -/* Return true if the HTX message is not empty and the HTX_BLK_FL_EOM flag is set - * on the tail block, which means the message is complete. Otherwise, false is - * returned. +/* Returns true if the end of the message was reached, i.e. if the HTX message is + * not empty and the HTX_BLK_FL_EOM flag is set on the tail block. Otherwise, + * false is returned. */ -static inline int htx_has_eom(const struct htx *htx) +static inline int htx_msg_ended(const struct htx *htx) { struct htx_blk *blk = htx_get_tail_blk(htx); @@ -535,7 +535,7 @@ static inline struct htx_blk *htx_add_header(struct htx *htx, const struct ist n if (name.len > HTX_HDR_NAME_MAX_LEN || value.len > HTX_HDR_VALUE_MAX_LEN) return NULL; - eom = htx_has_eom(htx); + eom = htx_msg_ended(htx); blk = __htx_add_blk(htx, HTX_BLK_HDR, name.len + value.len); if (!blk) return NULL; @@ -559,7 +559,7 @@ static inline struct htx_blk *htx_add_header(struct htx *htx, const struct ist n * EOM flag can only be carried by such a block. So a message already * ended must still be ended. */ - BUG_ON_HOT(eom && !htx_has_eom(htx)); + BUG_ON_HOT(eom && !htx_msg_ended(htx)); return blk; } @@ -579,7 +579,7 @@ static inline struct htx_blk *htx_add_trailer(struct htx *htx, const struct ist if (name.len > HTX_HDR_NAME_MAX_LEN || value.len > HTX_HDR_VALUE_MAX_LEN) return NULL; - eom = htx_has_eom(htx); + eom = htx_msg_ended(htx); blk = __htx_add_blk(htx, HTX_BLK_TLR, name.len + value.len); if (!blk) return NULL; @@ -603,7 +603,7 @@ static inline struct htx_blk *htx_add_trailer(struct htx *htx, const struct ist * EOM flag can only be carried by such a block. So a message already * ended must still be ended. */ - BUG_ON_HOT(eom && !htx_has_eom(htx)); + BUG_ON_HOT(eom && !htx_msg_ended(htx)); return blk; } @@ -849,12 +849,12 @@ static inline int htx_is_empty_noerr(const struct htx *htx) /* Returns 1 if more data are expected for the message . Otherwise it * returns 0. Note that it is illegal to call this with htx == NULL. This - * function relies on htx_has_eom() function. It means more data are always - * expected on tunnel mode. + * function relies on htx_msg_ended(). It means tunneled data are not + * considered here. */ static inline int htx_expect_more(const struct htx *htx) { - return !htx_has_eom(htx); + return !htx_msg_ended(htx); } /* Set EOM flag in . This function must always be called to report the end diff --git a/src/fcgi-app.c b/src/fcgi-app.c index 9b785b964..ddba737d3 100644 --- a/src/fcgi-app.c +++ b/src/fcgi-app.c @@ -343,7 +343,7 @@ static int fcgi_flt_http_headers(struct stream *s, struct filter *filter, struct sl = http_get_stline(htx); if (s->txn.http->meth != HTTP_METH_HEAD && sl && (msg->flags & (HTTP_MSGF_XFER_LEN|HTTP_MSGF_CNT_LEN|HTTP_MSGF_TE_CHNK)) == HTTP_MSGF_XFER_LEN && - htx_has_eom(htx)) { + htx_msg_ended(htx)) { struct htx_blk * blk; char *end; size_t len = 0; diff --git a/src/flt_decomp.c b/src/flt_decomp.c index d4294456c..67add1968 100644 --- a/src/flt_decomp.c +++ b/src/flt_decomp.c @@ -401,7 +401,7 @@ static int decomp_stream_blk(struct stream *s, struct filter *f, struct channel /* The decompression is finished and we must now be sure to * restore EOM on last block (possibly by adding an EOT). */ - if ((st->flags & DECOMP_STATE_EOM_SEEN) && !htx_has_eom(htx)) { + if ((st->flags & DECOMP_STATE_EOM_SEEN) && !htx_msg_ended(htx)) { unsigned int data = htx->data; BUG_ON(!(st->decomp_ctx->flags & DECOMP_CTX_FL_DONE) || st->decomp_ctx->drain_len); diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 7400be7b7..a5e3c0a6f 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -128,7 +128,7 @@ comp_prepare_compress_request(struct comp_state *st, struct stream *s, struct ht comp_type = NULL; /* compress only if body size is >= than the min size */ - if (((msg->flags & HTTP_MSGF_CNT_LEN) || htx_has_eom(htx)) && + if (((msg->flags & HTTP_MSGF_CNT_LEN) || htx_msg_ended(htx)) && ((s->be->comp && (comp_minsize = s->be->comp->minsize_req)) || (strm_fe(s)->comp && (comp_minsize = strm_fe(s)->comp->minsize_req)))) { /* small requests should not be compressed */ @@ -339,7 +339,7 @@ comp_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg, * message. In this case, it must be restored, * adding an EOT block to support it. */ - if (!htx_has_eom(htx)) { + if (!htx_msg_ended(htx)) { unsigned int data = htx->data; htx_set_eom(htx); @@ -686,7 +686,7 @@ select_compression_response_header(struct comp_state *st, struct stream *s, stru goto fail; /* compress only if body size is >= than the min size */ - if (((msg->flags & HTTP_MSGF_CNT_LEN) || htx_has_eom(htx)) && + if (((msg->flags & HTTP_MSGF_CNT_LEN) || htx_msg_ended(htx)) && ((s->be->comp && (comp_minsize = s->be->comp->minsize_res)) || (strm_fe(s)->comp && (comp_minsize = strm_fe(s)->comp->minsize_res)))) { /* small responses should not be compressed */ diff --git a/src/hlua.c b/src/hlua.c index 0d38e262c..d24f05977 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -7421,7 +7421,7 @@ static void _hlua_http_msg_delete(struct http_msg *msg, struct filter *filter, s /* Removed blocks may carry the EOM flag. In this case, the flag must be * set again on the last remaining block to keep the message complete. */ - eom = htx_has_eom(htx); + eom = htx_msg_ended(htx); /* Be sure is always the amount of DATA to remove */ if (htx->data == offset+len && htx_get_tail_type(htx) == HTX_BLK_DATA) { @@ -7493,7 +7493,7 @@ static void _hlua_http_msg_delete(struct http_msg *msg, struct filter *filter, s } end: - if (eom && !htx_has_eom(htx)) { + if (eom && !htx_msg_ended(htx)) { unsigned int data = htx->data; /* Restore the EOM flag. An EOT block may be added to carry it if @@ -7930,7 +7930,7 @@ __LJMP static int hlua_http_msg_unset_eom(lua_State *L) MAY_LJMP(check_args(L, 1, "set_eom")); msg = MAY_LJMP(hlua_checkhttpmsg(L, 1)); htx = htxbuf(&msg->chn->buf); - if (!htx_has_eom(htx)) + if (!htx_msg_ended(htx)) return 0; for (blk = htx_get_tail_blk(htx); blk; blk = htx_get_prev_blk(htx, blk)) { diff --git a/src/hq_interop.c b/src/hq_interop.c index 7b45e22fe..663e9fead 100644 --- a/src/hq_interop.c +++ b/src/hq_interop.c @@ -240,7 +240,7 @@ static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf, *fin = 0; htx = htx_from_buf(buf); /* EOM is saved here, useful if 0-copy is performed with HTX buf. */ - eom = htx_has_eom(htx); + eom = htx_msg_ended(htx); while (count && !htx_is_empty(htx) && qcc_stream_can_send(qcs)) { /* Not implemented : QUIC on backend side */ diff --git a/src/http_ana.c b/src/http_ana.c index 42c6bd505..cc5e0e58a 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -743,7 +743,7 @@ int http_process_request(struct stream *s, struct channel *req, int an_bit) * in case we previously disabled it, otherwise we might cause * the client to delay further data. */ - if ((sess->listener && (sess->listener->bind_conf->options & BC_O_NOQUICKACK)) && !htx_has_eom(htx)) + if ((sess->listener && (sess->listener->bind_conf->options & BC_O_NOQUICKACK)) && !htx_msg_ended(htx)) conn_set_quickack(cli_conn, 1); /************************************************************* @@ -992,7 +992,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit) else { c_adv(req, htx->data - co_data(req)); if ((global.tune.options & GTUNE_USE_FAST_FWD) && (msg->flags & HTTP_MSGF_XFER_LEN) && - (!(msg->flags & HTTP_MSGF_CONN_UPG) || htx_has_eom(htx))) + (!(msg->flags & HTTP_MSGF_CONN_UPG) || htx_msg_ended(htx))) channel_htx_forward_forever(req, htx); } @@ -1003,7 +1003,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit) * in HTTP_MSG_ENDING state. Then if all data was marked to be * forwarded, set the state to HTTP_MSG_DONE. */ - if (!htx_has_eom(htx)) + if (!htx_msg_ended(htx)) goto missing_data_or_waiting; msg->msg_state = HTTP_MSG_ENDING; @@ -2229,7 +2229,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit * in HTTP_MSG_ENDING state. Then if all data was marked to be * forwarded, set the state to HTTP_MSG_DONE. */ - if (!htx_has_eom(htx)) + if (!htx_msg_ended(htx)) goto missing_data_or_waiting; msg->msg_state = HTTP_MSG_ENDING; @@ -4372,7 +4372,7 @@ enum rule_result http_wait_for_msg_body(struct stream *s, struct channel *chn, /* Now we're are waiting for the payload. We just need to know if all * data have been received or if the buffer is full. */ - if (htx_has_eom(htx) || htx_get_tail_type(htx) > HTX_BLK_DATA) + if (htx_msg_ended(htx) || htx_get_tail_type(htx) > HTX_BLK_DATA) goto end; /* all data received */ if (bytes) { diff --git a/src/http_client.c b/src/http_client.c index 4bb9e1bac..df31a1168 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -577,7 +577,7 @@ void httpclient_applet_io_handler(struct appctx *appctx) goto out; } - if (htx_has_eom(htx)) { /* check if a body need to be added */ + if (htx_msg_ended(htx)) { /* check if a body need to be added */ appctx->st0 = HTTPCLIENT_S_RES_STLINE; applet_set_eoi(appctx); goto out; /* we need to leave the IO handler once we wrote the request */ @@ -640,7 +640,7 @@ void httpclient_applet_io_handler(struct appctx *appctx) htx = htxbuf(outbuf); /* if the request contains the EOM, we finished the request part. */ - if (htx_has_eom(htx)) { + if (htx_msg_ended(htx)) { appctx->st0 = HTTPCLIENT_S_RES_STLINE; applet_set_eoi(appctx); goto out; /* we need to leave the IO handler once we wrote the request */ @@ -668,7 +668,7 @@ void httpclient_applet_io_handler(struct appctx *appctx) htx = htxbuf(inbuf); if (htx_get_head_type(htx) != HTX_BLK_RES_SL) goto error; - res_has_eom = htx_has_eom(htx); + res_has_eom = htx_msg_ended(htx); blk = DISGUISE(htx_get_head_blk(htx)); sl = htx_get_blk_ptr(htx, blk); @@ -725,7 +725,7 @@ void httpclient_applet_io_handler(struct appctx *appctx) htx = htxbuf(inbuf); BUG_ON(htx_is_empty(htx)); - res_has_eom = htx_has_eom(htx); + res_has_eom = htx_msg_ended(htx); if (hc->options & HTTPCLIENT_O_RES_HTX) { /* HTX mode transfers the header to the hc buffer */ struct htx *hc_htx; @@ -814,7 +814,7 @@ void httpclient_applet_io_handler(struct appctx *appctx) applet_need_more_data(appctx); goto out; } - res_has_eom = htx_has_eom(htx); + res_has_eom = htx_msg_ended(htx); if (!b_alloc(&hc->res.buf, DB_MUX_TX)) { applet_wont_consume(appctx); diff --git a/src/http_htx.c b/src/http_htx.c index 62814772c..8c91ff5eb 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -2831,7 +2831,7 @@ smp_fetch_htx_has_eom(const struct arg *arg_p, struct sample *smp, const char *k if (!htx) return 0; - smp->data.u.sint = htx_has_eom(htx); + smp->data.u.sint = htx_msg_ended(htx); smp->data.type = SMP_T_BOOL; smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE; return 1; diff --git a/src/htx.c b/src/htx.c index 166fda059..d104e4874 100644 --- a/src/htx.c +++ b/src/htx.c @@ -386,7 +386,7 @@ struct htx_blk *__htx_add_blk(struct htx *htx, enum htx_blk_type type, uint32_t */ struct htx_blk *htx_add_blk(struct htx *htx, enum htx_blk_type type, uint32_t blksz) { - BUG_ON(htx_has_eom(htx)); + BUG_ON(htx_msg_ended(htx)); return __htx_add_blk(htx, type, blksz); } @@ -683,7 +683,7 @@ struct htx_blk *__htx_add_data_atonce(struct htx *htx, struct ist data) */ struct htx_blk *htx_add_data_atonce(struct htx *htx, struct ist data) { - BUG_ON(htx_has_eom(htx)); + BUG_ON(htx_msg_ended(htx)); return __htx_add_data_atonce(htx, data); } @@ -825,7 +825,7 @@ size_t htx_xfer(struct htx *dst, struct htx *src, size_t count, unsigned int fla uint32_t max, last_dstblk_sz; int dst_full = 0; - BUG_ON(htx_has_eom(dst)); + BUG_ON(htx_msg_ended(dst)); last_dstblk = NULL; last_dstblk_sz = 0; @@ -1091,7 +1091,7 @@ struct htx_ret htx_reserve_max_data(struct htx *htx) int32_t len = htx_free_data_space(htx); uint32_t flags = 0; - BUG_ON(htx_has_eom(htx)); + BUG_ON(htx_msg_ended(htx)); if (!len) return (struct htx_ret){.ret = 0, .blk = NULL}; @@ -1168,7 +1168,7 @@ size_t htx_add_data(struct htx *htx, const struct ist data) int32_t len = data.len; uint32_t flags = 0; - BUG_ON(htx_has_eom(htx)); + BUG_ON(htx_msg_ended(htx)); /* Not enough space to store data */ if (len > htx_free_data_space(htx)) @@ -1254,7 +1254,7 @@ size_t htx_add_data(struct htx *htx, const struct ist data) struct htx_blk *htx_add_last_data(struct htx *htx, struct ist data) { struct htx_blk *blk, *pblk; - int eom = htx_has_eom(htx); + int eom = htx_msg_ended(htx); /* Data may be added in a message already ended. In this case, the block * is first appended, after the block carrying the EOM flag, and then @@ -1285,7 +1285,7 @@ struct htx_blk *htx_add_last_data(struct htx *htx, struct ist data) /* The EOM flag was transferred on the new DATA block, or moved with the * blocks placed after it. So a message already ended must still be ended. */ - BUG_ON_HOT(eom && !htx_has_eom(htx)); + BUG_ON_HOT(eom && !htx_msg_ended(htx)); return blk; } @@ -1337,7 +1337,7 @@ int htx_append_msg(struct htx *dst, const struct htx *src) enum htx_blk_type type; uint32_t blksz, offset = dst->data; - BUG_ON(htx_has_eom(dst)); + BUG_ON(htx_msg_ended(dst)); for (blk = htx_get_head_blk(src); blk; blk = htx_get_next_blk(src, blk)) { type = htx_get_blk_type(blk); diff --git a/src/mux_h2.c b/src/mux_h2.c index 5cea5cab6..8c8f375ec 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -989,7 +989,7 @@ static inline int h2s_may_append_to_rxbuf(const struct h2s *h2s) * headers. So tunneled data must be stored in a separate buffer to * never mix HTTP data and tunneled data. */ - if (htx_has_eom(htx)) + if (htx_msg_ended(htx)) return 0; return !!htx_free_data_space(htx); @@ -8072,7 +8072,7 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in * these data must be transferred only once the upper layer has * consumed the HTTP part. */ - if (htx_has_eom(buf_htx)) { + if (htx_msg_ended(buf_htx)) { htx_to_buf(buf_htx, buf); htx_to_buf(h2s_htx, rxbuf); goto end; diff --git a/src/qcm_http.c b/src/qcm_http.c index 776f8cdf3..497aba0ff 100644 --- a/src/qcm_http.c +++ b/src/qcm_http.c @@ -33,7 +33,7 @@ size_t qcs_http_rcv_buf(struct qcs *qcs, struct buffer *buf, size_t count, cs_htx = htx_from_buf(buf); if (htx_is_empty_noerr(cs_htx) && htx_used_space(qcs_htx) <= count) { /* EOM will be copied to cs_htx via b_xfer(). */ - if (htx_has_eom(qcs_htx) && !(qcs->flags & QC_SF_EOI_SUSPENDED)) { + if (htx_msg_ended(qcs_htx) && !(qcs->flags & QC_SF_EOI_SUSPENDED)) { *fin = 1; } @@ -47,7 +47,7 @@ size_t qcs_http_rcv_buf(struct qcs *qcs, struct buffer *buf, size_t count, BUG_ON(qcs_htx->flags & HTX_FL_PARSING_ERROR); /* EOM was copied to cs_htx if all data were copied. */ - if (htx_has_eom(cs_htx)) { + if (htx_msg_ended(cs_htx)) { if (!(qcs->flags & QC_SF_EOI_SUSPENDED)) *fin = 1; } diff --git a/src/tcpcheck.c b/src/tcpcheck.c index 416086cdf..d0e9770d8 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -2000,7 +2000,7 @@ enum tcpcheck_eval_ret tcpcheck_eval_expect_http(struct check *check, struct tcp TRACE_ENTER(CHK_EV_TCPCHK_EXP, check); - last_read |= (!htx_free_data_space(htx) || htx_has_eom(htx)); + last_read |= (!htx_free_data_space(htx) || htx_msg_ended(htx)); if (htx->flags & HTX_FL_PARSING_ERROR) { TRACE_ERROR("invalid response", CHK_EV_TCPCHK_EXP|CHK_EV_TCPCHK_ERR, check);