From 62a81cb6a6d1a735b9d48a17fb57d98a55c2bbde Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 23 Jan 2024 07:51:24 +0100 Subject: [PATCH] MINOR: applet: Add callback function to deal with zero-copy forwarding This patch introduces the support for the callback function responsible to produce data via the zero-copy forwarding mechanism. There is no implementation for now. But field was added in the appctx structure to let an applet inform how much data it want to forward. It is not mandatory but it will be used during the zero-copy forwarding negociation. --- include/haproxy/applet-t.h | 3 ++- src/applet.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index f4e4241089..86e08c3195 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -63,7 +63,7 @@ struct applet { void (*fct)(struct appctx *); /* internal I/O handler, may never be NULL */ size_t (*rcv_buf)(struct stconn *sc, struct buffer *buf, size_t count, unsigned int flags); /* called from the upper layer to get data */ size_t (*snd_buf)(struct stconn *sc, struct buffer *buf, size_t count, unsigned int flags); /* Called from the upper layet to put data */ - /* TODO: ADD fastfwd callback functions */ + size_t (*fastfwd)(struct appctx *appctx, struct buffer *buf, size_t count, unsigned int flags); /* Callback to fast-forward data */ void (*release)(struct appctx *); /* callback to release resources, may be NULL */ unsigned int timeout; /* execution timeout. */ }; @@ -78,6 +78,7 @@ struct appctx { unsigned int flags; /* APPCTX_FL_* */ struct buffer inbuf; struct buffer outbuf; + size_t to_forward; struct buffer *chunk; /* used to store unfinished commands */ struct applet *applet; /* applet this context refers to */ diff --git a/src/applet.c b/src/applet.c index 2d88904f90..4ddb0da3bf 100644 --- a/src/applet.c +++ b/src/applet.c @@ -138,9 +138,9 @@ static void applet_trace(enum trace_level level, uint64_t mask, const struct tra if (src->verbosity == STRM_VERB_CLEAN) return; - chunk_appendf(&trace_buf, " appctx=%p .t=%p .t.exp=%d .flags=0x%x .st0=%d .st1=%d", + chunk_appendf(&trace_buf, " appctx=%p .t=%p .t.exp=%d .flags=0x%x .st0=%d .st1=%d to_fwd=%lu", appctx, appctx->t, tick_isset(appctx->t->expire) ? TICKS_TO_MS(appctx->t->expire - now_ms) : TICK_ETERNITY, - appctx->flags, appctx->st0, appctx->st1); + appctx->flags, appctx->st0, appctx->st1, appctx->to_forward); if (!sc || src->verbosity == STRM_VERB_MINIMAL) return; @@ -267,6 +267,7 @@ struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, int t appctx->flags = 0; appctx->inbuf = BUF_NULL; appctx->outbuf = BUF_NULL; + appctx->to_forward = 0; LIST_INIT(&appctx->buffer_wait.list); appctx->buffer_wait.target = appctx; -- 2.39.5