From b23edc8b8d049f72faef39cd734152d51b7f9448 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 24 May 2022 16:49:03 +0200 Subject: [PATCH] MINOR: stconn: rename SE_FL_RXBLK_CONN to SE_FL_APPLET_NEED_CONN This flag is exclusively used when a front applet needs to wait for the other side to connect (or fail to). Let's give it a more explicit name and remove the ambiguous function that was used only once. This also ensures we will not risk to set it back on a new endpoint after cs_reset_endp() via SE_FL_APP_MASK, because the flag being specific to the endpoint only and not to the connector, we don't want to preserve it when replacing the endpoint. --- dev/flags/flags.c | 2 +- include/haproxy/conn_stream-t.h | 2 +- include/haproxy/conn_stream.h | 16 +++++++--------- include/haproxy/cs_utils.h | 4 ++-- src/dns.c | 2 +- src/hlua.c | 2 +- src/sink.c | 4 ++-- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/dev/flags/flags.c b/dev/flags/flags.c index 5ce76e6b0..71a1874e0 100644 --- a/dev/flags/flags.c +++ b/dev/flags/flags.c @@ -187,7 +187,7 @@ void show_endp_flags(unsigned int f) SHOW_FLAG(f, SE_FL_RXBLK_CHAN); SHOW_FLAG(f, SE_FL_RXBLK_BUFF); SHOW_FLAG(f, SE_FL_RXBLK_ROOM); - SHOW_FLAG(f, SE_FL_RXBLK_CONN); + SHOW_FLAG(f, SE_FL_APPLET_NEED_CONN); SHOW_FLAG(f, SE_FL_RX_WAIT_EP); SHOW_FLAG(f, SE_FL_WANT_GET); SHOW_FLAG(f, SE_FL_WAIT_DATA); diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h index a29a18e28..599ee81de 100644 --- a/include/haproxy/conn_stream-t.h +++ b/include/haproxy/conn_stream-t.h @@ -79,7 +79,7 @@ enum se_flags { 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 */ /* unused 0x20000000,*/ - SE_FL_RXBLK_CONN = 0x40000000, /* other side is not connected */ + SE_FL_APPLET_NEED_CONN = 0x40000000, /* applet is waiting for the other side to (fail to) connect */ SE_FL_RXBLK_ANY = 0x5C000000, /* any of the RXBLK flags above */ SE_FL_APP_MASK = 0x5fe00000, /* Mask for flags set by the app layer */ }; diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h index 643d2bf99..490eecf1a 100644 --- a/include/haproxy/conn_stream.h +++ b/include/haproxy/conn_stream.h @@ -328,16 +328,14 @@ static inline void cs_rx_chan_blk(struct stconn *cs) sc_ep_set(cs, SE_FL_RXBLK_CHAN); } -/* Tell a stream connector the other side is connected */ -static inline void cs_rx_conn_rdy(struct stconn *cs) +/* An frontend (applet) stream endpoint tells the connector it needs the other + * side to connect or fail before continuing to work. This is used for example + * to allow an applet not to deliver data to a request channel before a + * connection is confirmed. + */ +static inline void se_need_remote_conn(struct sedesc *se) { - sc_ep_clr(cs, SE_FL_RXBLK_CONN); -} - -/* Tell a stream connector it must wait for the other side to connect */ -static inline void cs_rx_conn_blk(struct stconn *cs) -{ - sc_ep_set(cs, SE_FL_RXBLK_CONN); + se_fl_set(se, SE_FL_APPLET_NEED_CONN); } /* The stream connector just got the input buffer it was waiting for */ diff --git a/include/haproxy/cs_utils.h b/include/haproxy/cs_utils.h index a26011be3..9aceb9c52 100644 --- a/include/haproxy/cs_utils.h +++ b/include/haproxy/cs_utils.h @@ -296,8 +296,8 @@ static inline void cs_chk_rcv(struct stconn *cs) { struct channel *ic = sc_ic(cs); - if (sc_ep_test(cs, SE_FL_RXBLK_CONN) && cs_state_in(cs_opposite(cs)->state, SC_SB_RDY|SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) - cs_rx_conn_rdy(cs); + if (sc_ep_test(cs, SE_FL_APPLET_NEED_CONN) && cs_state_in(cs_opposite(cs)->state, SC_SB_RDY|SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) + sc_ep_clr(cs, SE_FL_APPLET_NEED_CONN); if (ic->flags & CF_SHUTR) return; diff --git a/src/dns.c b/src/dns.c index 422351b71..6156dbad6 100644 --- a/src/dns.c +++ b/src/dns.c @@ -473,7 +473,7 @@ static void dns_session_io_handler(struct appctx *appctx) */ if (cs_opposite(cs)->state < SC_ST_EST) { cs_cant_get(cs); - cs_rx_conn_blk(cs); + se_need_remote_conn(appctx->sedesc); cs_rx_endp_more(cs); return; } diff --git a/src/hlua.c b/src/hlua.c index 4fc952c39..26017555c 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1957,7 +1957,7 @@ static void hlua_socket_handler(struct appctx *appctx) */ if (cs_opposite(cs)->state < SC_ST_EST) { cs_cant_get(cs); - cs_rx_conn_blk(cs); + se_need_remote_conn(appctx->sedesc); cs_rx_endp_more(cs); return; } diff --git a/src/sink.c b/src/sink.c index 831c5b444..6bd30fcac 100644 --- a/src/sink.c +++ b/src/sink.c @@ -334,7 +334,7 @@ static void sink_forward_io_handler(struct appctx *appctx) */ if (cs_opposite(cs)->state < SC_ST_EST) { cs_cant_get(cs); - cs_rx_conn_blk(cs); + se_need_remote_conn(appctx->sedesc); cs_rx_endp_more(cs); return; } @@ -474,7 +474,7 @@ static void sink_forward_oc_io_handler(struct appctx *appctx) */ if (cs_opposite(cs)->state < SC_ST_EST) { cs_cant_get(cs); - cs_rx_conn_blk(cs); + se_need_remote_conn(appctx->sedesc); cs_rx_endp_more(cs); return; }