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.
This commit is contained in:
Christopher Faulet 2023-08-03 15:30:55 +02:00
parent e52519ac83
commit 1d68bebb70
4 changed files with 28 additions and 6 deletions

View File

@ -30,10 +30,16 @@
enum iobuf_flags { enum iobuf_flags {
IOBUF_FL_NONE = 0x00000000, /* For initialization purposes */ 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 iobuf {
struct pipe *pipe; /* non-NULL only when data present */ struct pipe *pipe; /* non-NULL only when data present */
struct buffer *buf;
size_t offset;
size_t data;
unsigned int flags; unsigned int flags;
}; };

View File

@ -124,12 +124,12 @@ static inline void se_expect_data(struct sedesc *se)
static inline unsigned int se_have_ff_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) 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));
} }

View File

@ -99,6 +99,8 @@ void sedesc_init(struct sedesc *sedesc)
se_fl_setall(sedesc, SE_FL_NONE); se_fl_setall(sedesc, SE_FL_NONE);
sedesc->iobuf.pipe = NULL; sedesc->iobuf.pipe = NULL;
sedesc->iobuf.buf = NULL;
sedesc->iobuf.offset = sedesc->iobuf.data = 0;
sedesc->iobuf.flags = IOBUF_FL_NONE; sedesc->iobuf.flags = IOBUF_FL_NONE;
} }

View File

@ -3307,6 +3307,14 @@ void strm_dump_to_buffer(struct buffer *buf, const struct stream *strm, const ch
chunk_appendf(buf, " wex=%s\n", 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)) : "<NEVER>"); sc_ep_snd_ex(scf) ? human_time(TICKS_TO_MS(sc_ep_snd_ex(scf) - now_ms), TICKS_TO_MS(1000)) : "<NEVER>");
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 = sc_conn(scf)) != NULL) {
if (conn->mux && conn->mux->show_sd) { if (conn->mux && conn->mux->show_sd) {
char muxpfx[100] = ""; 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", 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)) : "<NEVER>"); sc_ep_snd_ex(scb) ? human_time(TICKS_TO_MS(sc_ep_snd_ex(scb) - now_ms), TICKS_TO_MS(1000)) : "<NEVER>");
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 = sc_conn(scb)) != NULL) {
if (conn->mux && conn->mux->show_sd) { if (conn->mux && conn->mux->show_sd) {
char muxpfx[100] = ""; char muxpfx[100] = "";
@ -3408,12 +3424,11 @@ void strm_dump_to_buffer(struct buffer *buf, const struct stream *strm, const ch
} }
chunk_appendf(buf, 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", "%s an_exp=%s buf=%p data=%p o=%u p=%u i=%u size=%u\n",
pfx, pfx,
&strm->req, &strm->req,
strm->req.flags, strm->req.analysers, 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, strm->req.to_forward, strm->req.total,
pfx, pfx,
strm->req.analyse_exp ? 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, 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", "%s an_exp=%s buf=%p data=%p o=%u p=%u i=%u size=%u\n",
pfx, pfx,
&strm->res, &strm->res,
strm->res.flags, strm->res.analysers, 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, strm->res.to_forward, strm->res.total,
pfx, pfx,
strm->res.analyse_exp ? strm->res.analyse_exp ?