]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applet/stconn: Add a SE flag to specify an endpoint does not expect data
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 22 Feb 2023 13:22:56 +0000 (14:22 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 22 Feb 2023 14:56:28 +0000 (15:56 +0100)
An endpoint should now set SE_FL_EXP_NO_DATA flag if it does not expect any
data from the opposite endpoint. This way, the stream will be able to
disable any read timeout on the opposite endpoint. Applets should use
applet_expect_no_data() and applet_expect_data() functions to set or clear
the flag. For now, only dns and sink forwarder applets are concerned.

include/haproxy/applet.h
include/haproxy/stconn-t.h
src/dns.c
src/sink.c

index 4d32165d62392a85333d56b756f45fe6475437cc..5acdfdb20e55079e8f327742c483c7b8d49ce5fb 100644 (file)
@@ -166,6 +166,23 @@ static inline void applet_need_more_data(struct appctx *appctx)
        se_fl_set(appctx->sedesc, SE_FL_WAIT_DATA);
 }
 
+/* The applet indicates that it does not expect data from the opposite endpoint.
+ * This way the stream know it should not trigger read timeout on the other
+ * side.
+ */
+static inline void applet_expect_no_data(struct appctx *appctx)
+{
+       se_fl_set(appctx->sedesc, SE_FL_EXP_NO_DATA);
+}
+
+/* The applet indicates that it expects data from the opposite endpoint. This
+ * way the stream know it may trigger read timeout on the other side.
+ */
+static inline void applet_expect_data(struct appctx *appctx)
+{
+       se_fl_clr(appctx->sedesc, SE_FL_EXP_NO_DATA);
+}
+
 /* writes chunk <chunk> into the input channel of the stream attached to this
  * appctx's endpoint, and marks the SC_FL_NEED_ROOM on a channel full error.
  * See ci_putchk() for the list of return codes.
index 090487e1753a2015b8f3d539aabc63b2fd13979b..ea8e63eb9fd0a71919584057a58024f5b1212359 100644 (file)
@@ -67,17 +67,17 @@ enum se_flags {
        SE_FL_MAY_SPLICE = 0x00040000,  /* The endpoint may use the kernel splicing to forward data to the other side (implies SE_FL_CAN_SPLICE) */
        SE_FL_RCV_MORE   = 0x00080000,  /* Endpoint may have more bytes to transfer */
        SE_FL_WANT_ROOM  = 0x00100000,  /* More bytes to transfer, but not enough room */
-       SE_FL_ENDP_MASK  = 0x001ff000,  /* Mask for flags set by the endpoint */
+       SE_FL_EXP_NO_DATA= 0x00200000,  /* No data expected by the endpoint */
+       SE_FL_ENDP_MASK  = 0x002ff000,  /* Mask for flags set by the endpoint */
 
        /* following flags are supposed to be set by the app layer and read by
         * the endpoint :
         */
-       SE_FL_WAIT_FOR_HS   = 0x00200000,  /* This stream is waiting for handhskae */
-       SE_FL_KILL_CONN     = 0x00400000,  /* must kill the connection when the SC closes */
-       SE_FL_WAIT_DATA     = 0x00800000,  /* stream endpoint cannot work without more data from the stream's output */
-       SE_FL_WONT_CONSUME  = 0x01000000,  /* stream endpoint will not consume more data */
-       SE_FL_HAVE_NO_DATA  = 0x02000000,  /* the endpoint has no more data to deliver to the stream */
-       /* unused             0x04000000,*/
+       SE_FL_WAIT_FOR_HS   = 0x00400000,  /* This stream is waiting for handhskae */
+       SE_FL_KILL_CONN     = 0x00800000,  /* must kill the connection when the SC closes */
+       SE_FL_WAIT_DATA     = 0x01000000,  /* stream endpoint cannot work without more data from the stream's output */
+       SE_FL_WONT_CONSUME  = 0x02000000,  /* stream endpoint will not consume more data */
+       SE_FL_HAVE_NO_DATA  = 0x04000000,  /* the endpoint has no more data to deliver to the stream */
        /* unused             0x08000000,*/
        /* unused             0x10000000,*/
        /* unused             0x20000000,*/
@@ -98,9 +98,9 @@ static forceinline char *se_show_flags(char *buf, size_t len, const char *delim,
        _(SE_FL_SHRD, _(SE_FL_SHRR, _(SE_FL_SHWN, _(SE_FL_SHWS,
        _(SE_FL_NOT_FIRST, _(SE_FL_WEBSOCKET, _(SE_FL_EOI, _(SE_FL_EOS,
        _(SE_FL_ERROR, _(SE_FL_ERR_PENDING, _(SE_FL_MAY_SPLICE,
-       _(SE_FL_RCV_MORE, _(SE_FL_WANT_ROOM, _(SE_FL_WAIT_FOR_HS,
-       _(SE_FL_KILL_CONN, _(SE_FL_WAIT_DATA, _(SE_FL_WONT_CONSUME,
-       _(SE_FL_HAVE_NO_DATA, _(SE_FL_APPLET_NEED_CONN)))))))))))))))))))))));
+       _(SE_FL_RCV_MORE, _(SE_FL_WANT_ROOM, _(SE_FL_EXP_NO_DATA,
+       _(SE_FL_WAIT_FOR_HS, _(SE_FL_KILL_CONN, _(SE_FL_WAIT_DATA,
+       _(SE_FL_WONT_CONSUME, _(SE_FL_HAVE_NO_DATA, _(SE_FL_APPLET_NEED_CONN))))))))))))))))))))))));
        /* epilogue */
        _(~0U);
        return buf;
index 003169f61880f7e78e8f656a11828cb22afd7596..057935ab7937892b07d7bbaebe229d07568aa1ec 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -839,7 +839,7 @@ static int dns_session_init(struct appctx *appctx)
         * We are using a syslog server.
         */
        sc_ep_reset_rex(s->scb);
-
+       applet_expect_no_data(appctx);
        ds->appctx = appctx;
        return 0;
 
index d15de4ee618bc4507f89ee1379e304f327da311f..9c1c4d41af96adbadcaa63f08b7d41defb92cb59 100644 (file)
@@ -632,6 +632,7 @@ static int sink_forward_session_init(struct appctx *appctx)
         * We are using a syslog server.
         */
        sc_ep_reset_rex(s->scb);
+       applet_expect_no_data(appctx);
        sft->appctx = appctx;
 
        return 0;