From 4434b03358bda7d5d3fe8d50fff6a1a9d2b8c7ab Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 15 Jan 2024 18:35:14 +0100 Subject: [PATCH] MINIOR: applet: Add flags to deal with ends of input, ends of stream and errors Dedicated appctx flags to report EOI, EOS and errors (pending or terminal) were added with the functions to set these flags. It is pretty similar to what it done on most of muxes. --- include/haproxy/applet-t.h | 4 ++++ include/haproxy/applet.h | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index 71fb57ecd..9c70469c2 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -41,6 +41,10 @@ #define APPCTX_FL_INBLK_FULL 0x00000002 #define APPCTX_FL_OUTBLK_ALLOC 0x00000004 #define APPCTX_FL_OUTBLK_FULL 0x00000008 +#define APPCTX_FL_EOI 0x00000010 +#define APPCTX_FL_EOS 0x00000020 +#define APPCTX_FL_ERR_PENDING 0x00000040 +#define APPCTX_FL_ERROR 0x00000080 struct appctx; struct proxy; diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 6915eb3fc..dc9224b79 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -157,6 +157,9 @@ static forceinline void applet_fl_setall(struct appctx *appctx, uint all) static forceinline void applet_fl_set(struct appctx *appctx, uint on) { + if (((on & (APPCTX_FL_EOS|APPCTX_FL_EOI)) && appctx->flags & APPCTX_FL_ERR_PENDING) || + ((on & APPCTX_FL_ERR_PENDING) && appctx->flags & (APPCTX_FL_EOI|APPCTX_FL_EOS))) + on |= APPCTX_FL_ERROR; appctx->flags |= on; } @@ -175,6 +178,24 @@ static forceinline uint applet_fl_get(const struct appctx *appctx) return appctx->flags; } +static inline void applet_set_eoi(struct appctx *appctx) +{ + applet_fl_set(appctx, APPCTX_FL_EOI); +} + +static inline void applet_set_eos(struct appctx *appctx) +{ + applet_fl_set(appctx, APPCTX_FL_EOS); +} + +static inline void applet_set_error(struct appctx *appctx) +{ + if (applet_fl_test(appctx, (APPCTX_FL_EOS|APPCTX_FL_EOI))) + applet_fl_set(appctx, APPCTX_FL_ERROR); + else + applet_fl_set(appctx, APPCTX_FL_ERR_PENDING); +} + /* The applet announces it has more data to deliver to the stream's input * buffer. */