]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINIOR: applet: Add flags to deal with ends of input, ends of stream and errors
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 15 Jan 2024 17:35:14 +0000 (18:35 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Feb 2024 14:03:42 +0000 (15:03 +0100)
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
include/haproxy/applet.h

index 71fb57ecd96f22584845d48ab7cd838f756732bf..9c70469c2ad8aec80b150c2faeb6bd6f975d3cf4 100644 (file)
 #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;
index 6915eb3fc41a1f88a6f649e1820e411a40007796..dc9224b79e3872cdc1358142e359b2806b6b91ce 100644 (file)
@@ -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.
  */