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.
This commit is contained in:
Christopher Faulet 2023-02-22 14:22:56 +01:00
parent 4c13568b49
commit 2ca4cc1936
4 changed files with 29 additions and 11 deletions

View 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.

View 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;

View File

@ -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;

View 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;