From a1b5325a7a98759b4190753ed9fd0e763d150a36 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 5 Nov 2025 11:42:15 +0100 Subject: [PATCH] MINOR: channel: Remove total field from channels The field in the channel structure is now useless, so it can be removed. The field from the SC is used instead. This patch is related to issue #1617. --- include/haproxy/channel-t.h | 1 - include/haproxy/channel.h | 2 -- src/applet.c | 12 ++++++------ src/channel.c | 2 -- src/cli.c | 2 +- src/hq_interop.c | 2 +- src/http_ana.c | 2 -- src/stconn.c | 4 ---- src/stream.c | 21 +++++++++------------ 9 files changed, 17 insertions(+), 31 deletions(-) diff --git a/include/haproxy/channel-t.h b/include/haproxy/channel-t.h index 6972edbba2..20afe7d650 100644 --- a/include/haproxy/channel-t.h +++ b/include/haproxy/channel-t.h @@ -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) */ }; diff --git a/include/haproxy/channel.h b/include/haproxy/channel.h index 1faa4d0834..0c872dc314 100644 --- a/include/haproxy/channel.h +++ b/include/haproxy/channel.h @@ -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; } diff --git a/src/applet.c b/src/applet.c index 273c969748..6878474f15 100644 --- a/src/applet.c +++ b/src/applet.c @@ -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); diff --git a/src/channel.c b/src/channel.c index d120db79ea..972aad9429 100644 --- a/src/channel.c +++ b/src/channel.c @@ -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; } diff --git a/src/cli.c b/src/cli.c index 60e3eba735..12cd971fcb 100644 --- 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)); } diff --git a/src/hq_interop.c b/src/hq_interop.c index 74240a1f79..cf1cf7c83a 100644 --- a/src/hq_interop.c +++ b/src/hq_interop.c @@ -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("")); diff --git a/src/http_ana.c b/src/http_ana.c index 78391b59fd..11a0d4ad82 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -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; } diff --git a/src/stconn.c b/src/stconn.c index 41d0fe3965..f3b030fd68 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -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 diff --git a/src/stream.c b/src/stream.c index 65457601c2..0488bbb6cd 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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), -- 2.47.3