From: Christopher Faulet Date: Thu, 3 Aug 2023 13:30:55 +0000 (+0200) Subject: MINOR: stconn: Extend iobuf to handle a buffer in addition to a pipe X-Git-Tag: v2.9-dev8~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d68bebb7050d869a926a34441ce06ec7fcbe4d0;p=thirdparty%2Fhaproxy.git MINOR: stconn: Extend iobuf to handle a buffer in addition to a pipe It is unused for now, but the iobuf structure now owns a pointer to a buffer. This buffer will be used to perform mux-to-mux fast-forwarding when splicing is not supported or unusable. This pointer should be filled by an endpoint to let the opposite one forward data. Extra fields, in addition to the buffer, are mandatory because the buffer may already contains some data. the ".offset" field may be used may be used as the position to start to copy data. Finally, the amount of data copied in this buffer must be saved in ".data" field. Some flags are also added to prepare next changes. And helper stconn fnuctions are updated to also count data in the buffer. For a first implementation, it is not planned to handle data in the buffer and in the pipe in same time. But it will be possible to do so. --- diff --git a/include/haproxy/stconn-t.h b/include/haproxy/stconn-t.h index 39b479b0c2..1aace1287a 100644 --- a/include/haproxy/stconn-t.h +++ b/include/haproxy/stconn-t.h @@ -30,10 +30,16 @@ enum iobuf_flags { IOBUF_FL_NONE = 0x00000000, /* For initialization purposes */ + IOBUF_FL_NO_FF = 0x00000001, /* Fast-forwarding is not supported */ + IOBUF_FL_NO_SPLICING = 0x00000002, /* Splicing is not supported or unusable for this stream */ + IOBUF_FL_FF_BLOCKED = 0x00000004, /* Fast-forwarding is blocked (buffer allocation/full) */ }; struct iobuf { struct pipe *pipe; /* non-NULL only when data present */ + struct buffer *buf; + size_t offset; + size_t data; unsigned int flags; }; diff --git a/include/haproxy/stconn.h b/include/haproxy/stconn.h index d58fd791ee..12ac81b213 100644 --- a/include/haproxy/stconn.h +++ b/include/haproxy/stconn.h @@ -124,12 +124,12 @@ static inline void se_expect_data(struct sedesc *se) static inline unsigned int se_have_ff_data(struct sedesc *se) { - return ((long)se->iobuf.pipe); + return (se->iobuf.data | (long)se->iobuf.pipe); } static inline size_t se_ff_data(struct sedesc *se) { - return ((se->iobuf.pipe ? se->iobuf.pipe->data : 0)); + return (se->iobuf.data + (se->iobuf.pipe ? se->iobuf.pipe->data : 0)); } diff --git a/src/stconn.c b/src/stconn.c index 63d4383e09..f208678dab 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -99,6 +99,8 @@ void sedesc_init(struct sedesc *sedesc) se_fl_setall(sedesc, SE_FL_NONE); sedesc->iobuf.pipe = NULL; + sedesc->iobuf.buf = NULL; + sedesc->iobuf.offset = sedesc->iobuf.data = 0; sedesc->iobuf.flags = IOBUF_FL_NONE; } diff --git a/src/stream.c b/src/stream.c index 06db5636fb..6ccbe86235 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3307,6 +3307,14 @@ void strm_dump_to_buffer(struct buffer *buf, const struct stream *strm, const ch chunk_appendf(buf, " wex=%s\n", sc_ep_snd_ex(scf) ? human_time(TICKS_TO_MS(sc_ep_snd_ex(scf) - now_ms), TICKS_TO_MS(1000)) : ""); + chunk_appendf(&trash, "%s iobuf.flags=0x%08x .pipe=%d .buf=%u@%p+%u/%u\n", pfx, + scf->sedesc->iobuf.flags, + scf->sedesc->iobuf.pipe ? scf->sedesc->iobuf.pipe->data : 0, + scf->sedesc->iobuf.buf ? (unsigned int)b_data(scf->sedesc->iobuf.buf): 0, + scf->sedesc->iobuf.buf ? b_orig(scf->sedesc->iobuf.buf): NULL, + scf->sedesc->iobuf.buf ? (unsigned int)b_head_ofs(scf->sedesc->iobuf.buf): 0, + scf->sedesc->iobuf.buf ? (unsigned int)b_size(scf->sedesc->iobuf.buf): 0); + if ((conn = sc_conn(scf)) != NULL) { if (conn->mux && conn->mux->show_sd) { char muxpfx[100] = ""; @@ -3356,6 +3364,14 @@ void strm_dump_to_buffer(struct buffer *buf, const struct stream *strm, const ch chunk_appendf(buf, " wex=%s\n", sc_ep_snd_ex(scb) ? human_time(TICKS_TO_MS(sc_ep_snd_ex(scb) - now_ms), TICKS_TO_MS(1000)) : ""); + chunk_appendf(&trash, "%s iobuf.flags=0x%08x .pipe=%d .buf=%u@%p+%u/%u\n", pfx, + scb->sedesc->iobuf.flags, + scb->sedesc->iobuf.pipe ? scb->sedesc->iobuf.pipe->data : 0, + scb->sedesc->iobuf.buf ? (unsigned int)b_data(scb->sedesc->iobuf.buf): 0, + scb->sedesc->iobuf.buf ? b_orig(scb->sedesc->iobuf.buf): NULL, + scb->sedesc->iobuf.buf ? (unsigned int)b_head_ofs(scb->sedesc->iobuf.buf): 0, + scb->sedesc->iobuf.buf ? (unsigned int)b_size(scb->sedesc->iobuf.buf): 0); + if ((conn = sc_conn(scb)) != NULL) { if (conn->mux && conn->mux->show_sd) { char muxpfx[100] = ""; @@ -3408,12 +3424,11 @@ void strm_dump_to_buffer(struct buffer *buf, const struct stream *strm, const ch } chunk_appendf(buf, - "%s req=%p (f=0x%06x an=0x%x pipe=%d tofwd=%d total=%lld)\n" + "%s req=%p (f=0x%06x an=0x%x tofwd=%d total=%lld)\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->scb->sedesc->iobuf.pipe ? strm->scb->sedesc->iobuf.pipe->data : 0, strm->req.to_forward, strm->req.total, pfx, strm->req.analyse_exp ? @@ -3441,12 +3456,11 @@ void strm_dump_to_buffer(struct buffer *buf, const struct stream *strm, const ch } chunk_appendf(buf, - "%s res=%p (f=0x%06x an=0x%x pipe=%d tofwd=%d total=%lld)\n" + "%s res=%p (f=0x%06x an=0x%x tofwd=%d total=%lld)\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->scf->sedesc->iobuf.pipe ? strm->scf->sedesc->iobuf.pipe->data : 0, strm->res.to_forward, strm->res.total, pfx, strm->res.analyse_exp ?