]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: channel: Remove total field from channels
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Nov 2025 10:42:15 +0000 (11:42 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Nov 2025 14:01:29 +0000 (15:01 +0100)
The <total> field in the channel structure is now useless, so it can be
removed. The <bytes_in> field from the SC is used instead.

This patch is related to issue #1617.

include/haproxy/channel-t.h
include/haproxy/channel.h
src/applet.c
src/channel.c
src/cli.c
src/hq_interop.c
src/http_ana.c
src/stconn.c
src/stream.c

index 6972edbba2eafe620abce1c0da0ed40a86a76031..20afe7d6508887743c6842ea77266b91774aa8e5 100644 (file)
@@ -204,7 +204,6 @@ struct channel {
        unsigned short last_read;       /* 16 lower bits of last read date (max pause=65s) */
        unsigned char xfer_large;       /* number of consecutive large xfers */
        unsigned char xfer_small;       /* number of consecutive small xfers */
-       unsigned long long total;       /* total data read */
        int analyse_exp;                /* expiration date for current analysers (if set) */
 };
 
index 1faa4d08346e1717bf17ef7cbe238b0b0f81bdec..0c872dc314189d3a11274c5cb7de28ee35927097 100644 (file)
@@ -323,7 +323,6 @@ static inline void channel_init(struct channel *chn)
        chn->to_forward = 0;
        chn->last_read = now_ms;
        chn->xfer_small = chn->xfer_large = 0;
-       chn->total = 0;
        chn->analysers = 0;
        chn->flags = 0;
        chn->output = 0;
@@ -377,7 +376,6 @@ static inline void channel_add_input(struct channel *chn, unsigned int len)
                c_adv(chn, fwd);
        }
        /* notify that some data was read */
-       chn->total += len;
        chn->flags |= CF_READ_EVENT;
 }
 
index 273c969748d82a9063c423286b49eebca191e872..6878474f15fd5ce3dffab0e815a32b1538961de2 100644 (file)
@@ -167,12 +167,12 @@ static void applet_trace(enum trace_level level, uint64_t mask, const struct tra
                              oc, oc->flags, tick_isset(oc->analyse_exp) ? TICKS_TO_MS(oc->analyse_exp - now_ms) : TICK_ETERNITY);
        }
        else {
-               chunk_appendf(&trace_buf, " ic=(%p .fl=0x%08x .ana=0x%08x .exp=%u .o=%lu .tot=%llu .to_fwd=%u)",
+               chunk_appendf(&trace_buf, " ic=(%p .fl=0x%08x .ana=0x%08x .exp=%u .o=%lu .to_fwd=%u)",
                              ic, ic->flags, ic->analysers, ic->analyse_exp,
-                             (long)ic->output, ic->total, ic->to_forward);
-               chunk_appendf(&trace_buf, " oc=(%p .fl=0x%08x .ana=0x%08x .exp=%u .o=%lu .tot=%llu .to_fwd=%u)",
+                             (long)ic->output, ic->to_forward);
+               chunk_appendf(&trace_buf, " oc=(%p .fl=0x%08x .ana=0x%08x .exp=%u .o=%lu .to_fwd=%u)",
                              oc, oc->flags, oc->analysers, oc->analyse_exp,
-                             (long)oc->output, oc->total, oc->to_forward);
+                             (long)oc->output, oc->to_forward);
        }
 
        if (src->verbosity == STRM_VERB_SIMPLE ||
@@ -846,7 +846,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
 
        sc_ep_fwd_kip(sco, sc);
 
-       input  = ic->total;
+       input  = applet_output_data(app);
        output = co_data(oc);
        app->applet->fct(app);
 
@@ -866,7 +866,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
                        sc_have_room(sco);
        }
 
-       input = ic->total - input;
+       input = applet_output_data(app) - input;
        if (input) {
                channel_check_xfer(ic, input);
                sc_ep_report_read_activity(sc);
index d120db79eafa50d95f430315ae24a3f565737607..972aad9429f075792b2277934d22dda9b01d1c8e 100644 (file)
@@ -98,7 +98,6 @@ int co_inject(struct channel *chn, const char *msg, int len)
        memcpy(co_tail(chn), msg, len);
        b_add(&chn->buf, len);
        c_adv(chn, len);
-       chn->total += len;
        return -1;
 }
 
@@ -127,7 +126,6 @@ int ci_putchr(struct channel *chn, char c)
                c_adv(chn, 1);
        }
 
-       chn->total++;
        return 1;
 }
 
index 60e3eba7351d736ac3da3bb656d9a7880f95110f..12cd971fcbf6040921aab6d3ea75f137f6810bb3 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -3502,7 +3502,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
 
                if (do_log &&
                    !(s->flags & SF_MONITOR) &&
-                   (!(fe->options & PR_O_NULLNOLOG) || s->req.total)) {
+                   (!(fe->options & PR_O_NULLNOLOG) || s->scf->bytes_in)) {
                        s->do_log(s, log_orig(LOG_ORIG_TXN_CLOSE, LOG_ORIG_FL_NONE));
                }
 
index 74240a1f79bd1456d43c6a11e2f5b33fc8251819..cf1cf7c83afb243be5228942af85f870e8f85297 100644 (file)
@@ -110,7 +110,7 @@ static ssize_t hq_interop_rcv_buf_res(struct qcs *qcs, struct buffer *b, int fin
        BUG_ON(!htx_buf);
        htx = htx_from_buf(htx_buf);
 
-       if (htx_is_empty(htx) && !strm->res.total) {
+       if (htx_is_empty(htx) && !strm->scb->bytes_in) {
                /* First data transfer, add HTX response start-line first. */
                sl = htx_add_stline(htx, HTX_BLK_RES_SL, flags,
                                    ist("HTTP/1.0"), ist("200"), ist(""));
index 78391b59fde41e75abdb2711dfec923c222361b3..11a0d4ad82f7c19f07dc3bd27792cfbdf743c3f7 100644 (file)
@@ -1215,7 +1215,6 @@ static __inline int do_l7_retry(struct stream *s, struct stconn *sc)
        stream_choose_redispatch(s);
        res->to_forward = 0;
        res->analyse_exp = TICK_ETERNITY;
-       res->total = 0;
 
        s->scb->flags &= ~(SC_FL_ERROR|SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED);
        if (sc_reset_endp(s->scb) < 0) {
@@ -4707,7 +4706,6 @@ int http_forward_proxy_resp(struct stream *s, int final)
        data = htx->data - co_data(res);
        c_adv(res, data);
        htx->first = -1;
-       res->total += data;
        return 1;
 }
 
index 41d0fe3965f81fb2db3c7d072a1b31f2caf299c9..f3b030fd6878f55a0b6f31e310c9861d3263e625 100644 (file)
@@ -1355,7 +1355,6 @@ int sc_conn_recv(struct stconn *sc)
                        if (ic->to_forward != CHN_INFINITE_FORWARD)
                                ic->to_forward -= ret;
                        sc->bytes_in += ret;
-                       ic->total += ret;
                        cur_read += ret;
                        ic->flags |= CF_READ_EVENT;
                }
@@ -1458,7 +1457,6 @@ int sc_conn_recv(struct stconn *sc)
 
                ic->flags |= CF_READ_EVENT;
                sc->bytes_in += ret;
-               ic->total += ret;
 
                /* End-of-input reached, we can leave. In this case, it is
                 * important to break the loop to not block the SC because of
@@ -2039,7 +2037,6 @@ int sc_applet_recv(struct stconn *sc)
                        if (ic->to_forward != CHN_INFINITE_FORWARD)
                                ic->to_forward -= ret;
                        sc->bytes_in += ret;
-                       ic->total += ret;
                        cur_read += ret;
                        ic->flags |= CF_READ_EVENT;
                }
@@ -2123,7 +2120,6 @@ int sc_applet_recv(struct stconn *sc)
 
        ic->flags |= CF_READ_EVENT;
        sc->bytes_in += ret;
-       ic->total += ret;
 
        /* End-of-input reached, we can leave. In this case, it is
         * important to break the loop to not block the SC because of
index 65457601c22a23a81f4bc6a1969ad902fa5bf0fa..0488bbb6cdd4892efe490ec7a5795eb3de8656ea 100644 (file)
@@ -230,12 +230,12 @@ static void strm_trace(enum trace_level level, uint64_t mask, const struct trace
                              res, res->flags, tick_isset(res->analyse_exp) ? TICKS_TO_MS(res->analyse_exp - now_ms) : TICK_ETERNITY);
        }
        else {
-               chunk_appendf(&trace_buf, " req=(%p .fl=0x%08x .ana=0x%08x .exp=%u .o=%lu .tot=%llu .to_fwd=%u)",
+               chunk_appendf(&trace_buf, " req=(%p .fl=0x%08x .ana=0x%08x .exp=%u .o=%lu .to_fwd=%u)",
                              req, req->flags, req->analysers, req->analyse_exp,
-                             (long)req->output, req->total, req->to_forward);
-               chunk_appendf(&trace_buf, " res=(%p .fl=0x%08x .ana=0x%08x .exp=%u .o=%lu .tot=%llu .to_fwd=%u)",
+                             (long)req->output, req->to_forward);
+               chunk_appendf(&trace_buf, " res=(%p .fl=0x%08x .ana=0x%08x .exp=%u .o=%lu .to_fwd=%u)",
                              res, res->flags, res->analysers, res->analyse_exp,
-                             (long)res->output, res->total, res->to_forward);
+                             (long)res->output, res->to_forward);
        }
 
        if (src->verbosity == STRM_VERB_SIMPLE ||
@@ -298,7 +298,6 @@ int stream_upgrade_from_sc(struct stconn *sc, struct buffer *input)
                 */
                s->req.buf = *input;
                *input = BUF_NULL;
-               s->req.total = (IS_HTX_STRM(s) ? htxbuf(&s->req.buf)->data : b_data(&s->req.buf));
                s->scf->bytes_in = (IS_HTX_STRM(s) ? htxbuf(&s->req.buf)->data : b_data(&s->req.buf));
                sc_ep_report_read_activity(s->scf);
        }
@@ -574,7 +573,6 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
                 */
                s->req.buf = *input;
                *input = BUF_NULL;
-               s->req.total = (IS_HTX_STRM(s) ? htxbuf(&s->req.buf)->data : b_data(&s->req.buf));
                s->scf->bytes_in = (IS_HTX_STRM(s) ? htxbuf(&s->req.buf)->data : b_data(&s->req.buf));
                sc_ep_report_read_activity(s->scf);
        }
@@ -1554,7 +1552,6 @@ int stream_set_http_mode(struct stream *s, const struct mux_proto_list *mux_prot
                sc_conn_commit_endp_upgrade(sc);
 
                s->req.flags &= ~(CF_READ_EVENT|CF_AUTO_CONNECT);
-               s->req.total = 0;
                s->flags |= SF_IGNORE;
                if (sc_ep_test(sc, SE_FL_DETACHED)) {
                        /* If stream connector is detached, it means it was not
@@ -2704,7 +2701,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
 
                if (do_log &&
                    !(s->flags & SF_MONITOR) &&
-                   (!(sess->fe->options & PR_O_NULLNOLOG) || req->total)) {
+                   (!(sess->fe->options & PR_O_NULLNOLOG) || s->scf->bytes_in)) {
                        /* we may need to know the position in the queue */
                        pendconn_free(s);
 
@@ -3703,12 +3700,12 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx
        }
 
        chunk_appendf(buf,
-                    "%s  req=%p (f=0x%06x an=0x%x tofwd=%d total=%lld)\n"
+                    "%s  req=%p (f=0x%06x an=0x%x tofwd=%d)\n"
                     "%s      an_exp=%s buf=%p data=%p o=%u p=%u i=%u size=%u\n",
                     pfx,
                     &strm->req,
                     strm->req.flags, strm->req.analysers,
-                    strm->req.to_forward, strm->req.total,
+                    strm->req.to_forward,
                     pfx,
                     strm->req.analyse_exp ?
                     human_time(TICKS_TO_MS(strm->req.analyse_exp - now_ms),
@@ -3735,12 +3732,12 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx
        }
 
        chunk_appendf(buf,
-                    "%s  res=%p (f=0x%06x an=0x%x tofwd=%d total=%lld)\n"
+                    "%s  res=%p (f=0x%06x an=0x%x tofwd=%d)\n"
                     "%s      an_exp=%s buf=%p data=%p o=%u p=%u i=%u size=%u\n",
                     pfx,
                     &strm->res,
                     strm->res.flags, strm->res.analysers,
-                    strm->res.to_forward, strm->res.total,
+                    strm->res.to_forward,
                     pfx,
                     strm->res.analyse_exp ?
                     human_time(TICKS_TO_MS(strm->res.analyse_exp - now_ms),