From: Willy Tarreau Date: Wed, 25 May 2022 14:01:38 +0000 (+0200) Subject: CLEANUP: stconn: rename SE_FL_RX_WAIT_EP to SE_FL_HAVE_NO_DATA X-Git-Tag: v2.6-dev12~56 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c02f8de143a1ae49051c7dd91bcbda8e76ce52b;p=thirdparty%2Fhaproxy.git CLEANUP: stconn: rename SE_FL_RX_WAIT_EP to SE_FL_HAVE_NO_DATA It's more explicit this way. The cs_rx_endp_ready() function could be removed so that the flag is directly tested. In the future it should be inverted and the few places where it's set (or preserved via SE_FL_APP_MASK) could be dropped. --- diff --git a/dev/flags/flags.c b/dev/flags/flags.c index 71a1874e05..19036a37dd 100644 --- a/dev/flags/flags.c +++ b/dev/flags/flags.c @@ -188,7 +188,7 @@ void show_endp_flags(unsigned int f) SHOW_FLAG(f, SE_FL_RXBLK_BUFF); SHOW_FLAG(f, SE_FL_RXBLK_ROOM); SHOW_FLAG(f, SE_FL_APPLET_NEED_CONN); - SHOW_FLAG(f, SE_FL_RX_WAIT_EP); + SHOW_FLAG(f, SE_FL_HAVE_NO_DATA); SHOW_FLAG(f, SE_FL_WANT_GET); SHOW_FLAG(f, SE_FL_WAIT_DATA); SHOW_FLAG(f, SE_FL_KILL_CONN); diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 9e5e44fd77..5fc62498ef 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -133,7 +133,7 @@ static inline struct stream *appctx_strm(const struct appctx *appctx) */ static inline void applet_have_more_data(struct appctx *appctx) { - se_fl_clr(appctx->sedesc, SE_FL_RX_WAIT_EP); + se_fl_clr(appctx->sedesc, SE_FL_HAVE_NO_DATA); } /* The applet announces it doesn't have more data for the stream's input @@ -141,7 +141,7 @@ static inline void applet_have_more_data(struct appctx *appctx) */ static inline void applet_have_no_more_data(struct appctx *appctx) { - se_fl_set(appctx->sedesc, SE_FL_RX_WAIT_EP); + se_fl_set(appctx->sedesc, SE_FL_HAVE_NO_DATA); } /* writes chunk into the input channel of the stream attached to this diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h index 6ec87c83a7..1aa61158c0 100644 --- a/include/haproxy/conn_stream-t.h +++ b/include/haproxy/conn_stream-t.h @@ -74,7 +74,7 @@ enum se_flags { SE_FL_KILL_CONN = 0x00400000, /* must kill the connection when the CS closes */ SE_FL_WAIT_DATA = 0x00800000, /* CS waits for more outgoing data to send */ SE_FL_WANT_GET = 0x01000000, /* CS would like to get some data from the buffer */ - SE_FL_RX_WAIT_EP = 0x02000000, /* CS waits for more data from the end point */ + SE_FL_HAVE_NO_DATA = 0x02000000, /* the endpoint has no more data to deliver to the stream */ SE_FL_RXBLK_CHAN = 0x04000000, /* the channel doesn't want the CS to introduce data */ SE_FL_RXBLK_BUFF = 0x08000000, /* CS waits for a buffer allocation to complete */ SE_FL_RXBLK_ROOM = 0x10000000, /* CS waits for more buffer room to store incoming data */ diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h index b98f5db45b..296a85374f 100644 --- a/include/haproxy/conn_stream.h +++ b/include/haproxy/conn_stream.h @@ -299,18 +299,12 @@ static inline int sc_waiting_room(const struct stconn *cs) return !!sc_ep_test(cs, SE_FL_RXBLK_ROOM); } -/* Returns non-zero if the stream connector's endpoint is ready to receive */ -static inline int cs_rx_endp_ready(const struct stconn *cs) -{ - return !sc_ep_test(cs, SE_FL_RX_WAIT_EP); -} - /* The stream endpoint announces it has more data to deliver to the stream's * input buffer. */ static inline void se_have_more_data(struct sedesc *se) { - se_fl_clr(se, SE_FL_RX_WAIT_EP); + se_fl_clr(se, SE_FL_HAVE_NO_DATA); } /* The stream endpoint announces it doesn't have more data for the stream's @@ -318,7 +312,7 @@ static inline void se_have_more_data(struct sedesc *se) */ static inline void se_have_no_more_data(struct sedesc *se) { - se_fl_set(se, SE_FL_RX_WAIT_EP); + se_fl_set(se, SE_FL_HAVE_NO_DATA); } /* The application layer informs a stream connector that it's willing to @@ -358,7 +352,7 @@ static inline void sc_have_buff(struct stconn *cs) /* The stream connector failed to get an input buffer and is waiting for it. * It indicates a willingness to deliver data to the buffer that will have to - * be retried, as such, callers will often automatically clear RXBLK_ENDP to be + * be retried. As such, callers will often automatically clear SE_FL_HAVE_NO_DATA * called again as soon as RXBLK_BUFF is cleared. */ static inline void sc_need_buff(struct stconn *cs) @@ -378,7 +372,7 @@ static inline void sc_have_room(struct stconn *cs) /* The stream connector announces it failed to put data into the input buffer * by lack of room. Since it indicates a willingness to deliver data to the * buffer that will have to be retried. Usually the caller will also clear - * RXBLK_ENDP to be called again as soon as RXBLK_ROOM is cleared. + * SE_FL_HAVE_NO_DATA to be called again as soon as RXBLK_ROOM is cleared. */ static inline void sc_need_room(struct stconn *cs) { diff --git a/include/haproxy/cs_utils.h b/include/haproxy/cs_utils.h index 8593dd1f4c..13f29e3388 100644 --- a/include/haproxy/cs_utils.h +++ b/include/haproxy/cs_utils.h @@ -151,7 +151,7 @@ static inline int cs_is_conn_error(const struct stconn *cs) * failure, non-zero otherwise. If no buffer is available, the requester, * represented by the pointer, will be added in the list of objects * waiting for an available buffer, and SE_FL_RXBLK_BUFF will be set on the - * stream connector and SE_FL_RX_WAIT_EP cleared. The requester will be responsible + * stream connector and SE_FL_HAVE_NO_DATA cleared. The requester will be responsible * for calling this function to try again once woken up. */ static inline int cs_alloc_ibuf(struct stconn *cs, struct buffer_wait *wait) @@ -304,7 +304,10 @@ static inline int sc_is_recv_allowed(const struct stconn *sc) if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN)) return 0; - return cs_rx_endp_ready(sc) && !cs_rx_blocked(sc); + if (sc_ep_test(sc, SE_FL_HAVE_NO_DATA)) + return 0; + + return !cs_rx_blocked(sc); } /* This is to be used after making some room available in a channel. It will @@ -325,7 +328,7 @@ static inline void cs_chk_rcv(struct stconn *cs) if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST)) return; - sc_ep_set(cs, SE_FL_RX_WAIT_EP); + sc_ep_set(cs, SE_FL_HAVE_NO_DATA); if (likely(cs->app_ops->chk_rcv)) cs->app_ops->chk_rcv(cs); } diff --git a/src/conn_stream.c b/src/conn_stream.c index 9ebc0c56e3..284fa52adf 100644 --- a/src/conn_stream.c +++ b/src/conn_stream.c @@ -1919,7 +1919,7 @@ static int cs_applet_process(struct stconn *cs) /* If the applet wants to write and the channel is closed, it's a * broken pipe and it must be reported. */ - if (!sc_ep_test(cs, SE_FL_RX_WAIT_EP) && (ic->flags & CF_SHUTR)) + if (!sc_ep_test(cs, SE_FL_HAVE_NO_DATA) && (ic->flags & CF_SHUTR)) sc_ep_set(cs, SE_FL_ERROR); /* automatically mark the applet having data available if it reported