From: Christopher Faulet Date: Mon, 15 Jan 2024 17:35:14 +0000 (+0100) Subject: MINIOR: applet: Add flags to deal with ends of input, ends of stream and errors X-Git-Tag: v3.0-dev3~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4434b03358bda7d5d3fe8d50fff6a1a9d2b8c7ab;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index 71fb57ecd9..9c70469c2a 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 6915eb3fc4..dc9224b79e 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. */