From: Christopher Faulet Date: Wed, 22 Feb 2023 13:22:56 +0000 (+0100) Subject: MINOR: applet/stconn: Add a SE flag to specify an endpoint does not expect data X-Git-Tag: v2.8-dev5~129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ca4cc1936c16db030f3cb66eaa628518984edb8;p=thirdparty%2Fhaproxy.git MINOR: applet/stconn: Add a SE flag to specify an endpoint does not expect data 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. --- diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 4d32165d62..5acdfdb20e 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -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 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. diff --git a/include/haproxy/stconn-t.h b/include/haproxy/stconn-t.h index 090487e175..ea8e63eb9f 100644 --- a/include/haproxy/stconn-t.h +++ b/include/haproxy/stconn-t.h @@ -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; diff --git a/src/dns.c b/src/dns.c index 003169f618..057935ab79 100644 --- 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; diff --git a/src/sink.c b/src/sink.c index d15de4ee61..9c1c4d41af 100644 --- a/src/sink.c +++ b/src/sink.c @@ -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;