]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: htx: Rename htx_has_eom() into htx_msg_ended()
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 15 Sep 2026 11:58:16 +0000 (13:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Sep 2026 15:05:18 +0000 (17:05 +0200)
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.

13 files changed:
include/haproxy/htx.h
src/fcgi-app.c
src/flt_decomp.c
src/flt_http_comp.c
src/hlua.c
src/hq_interop.c
src/http_ana.c
src/http_client.c
src/http_htx.c
src/htx.c
src/mux_h2.c
src/qcm_http.c
src/tcpcheck.c

index 234dfc58797694331d012906f3f913f64412586e..14f4e3c86acb7a204db543c303a6dc9b2b1fef7c 100644 (file)
@@ -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 <htx>. 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 <htx>. This function must always be called to report the end
index 9b785b964b2e2aa3d14055ba67f4ffcffc9a3361..ddba737d31fc558d6cf03050936c267648dd4880 100644 (file)
@@ -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;
index d4294456c8b3ca8be6c963d63f0b33908d35ea14..67add1968c128bd9302c793e0637bea20afdfc7a 100644 (file)
@@ -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);
index 7400be7b7dfa7e7deb2115b8b071893f17952557..a5e3c0a6fc9a62cfdb7d24879a236711cd9b539c 100644 (file)
@@ -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 */
index 0d38e262cda989b3c937408f08eacf381a390060..d24f059772bca42f7c079dc53103a1735a9fff56 100644 (file)
@@ -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 <len> 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)) {
index 7b45e22fe1923ba43f64780f4ef3215312541fb5..663e9fead22391fc599192e8cf14e88548154627 100644 (file)
@@ -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 */
index 42c6bd505e27de8c3bf05486d608d2d17914ca6e..cc5e0e58a77cce51ed9a63b76b0b894b9f4d99bb 100644 (file)
@@ -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) {
index 4bb9e1bac6484f40bb837f55cb33234f701db13e..df31a11688cae7f472627487a079605d86c09ea2 100644 (file)
@@ -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);
index 62814772cff049d6954c2a852bf6c6208b57c9fb..8c91ff5eb0eff674758d0aeee1abf3e9a436a7ac 100644 (file)
@@ -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;
index 166fda0593c8cc7930d1ba74a2caab5daee57639..d104e48740f2b256d34bbd56129d719fb01c964d 100644 (file)
--- 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);
index 5cea5cab6eedd5f3a4f9ea0153c4befbd656a8fc..8c8f375ec723ede8189f64da7cdc70fa894e7b1c 100644 (file)
@@ -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;
index 776f8cdf3b0181bc043174a42964ece98a7c9720..497aba0fff73a728723f84218d4588eb69a5bb2d 100644 (file)
@@ -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;
        }
index 416086cdfe2ce3149fe6c958d1178938bc9075da..d0e9770d81eff6b87d247af60a3521aec8bb7c59 100644 (file)
@@ -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);