MEDIUM: stconn: take SE_FL_APPLET_NEED_CONN out of the RXBLK_ANY flags

This makes SE_FL_APPLET_NEED_CONN autonomous, in that we check for it
everywhere we have a relevant cs_rx_blocked(), so that the flag doesn't
need anymore to be covered by cs_rx_blocked(). Indeed, this flag doesn't
really translate a receive blocking condition but rather a refusal to
wake up an applet that is waiting for a connection to finish to setup.

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.

It's possible that cs_chk_rcv() could later be further simplified if
we can demonstrate that the two tests in it can be merged.
diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h
index 599ee81..6ec87c8 100644
--- a/include/haproxy/conn_stream-t.h
+++ b/include/haproxy/conn_stream-t.h
@@ -78,10 +78,10 @@
 	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 */
+	SE_FL_RXBLK_ANY     = 0x1C000000,  /* any of the RXBLK flags above */
+	SE_FL_APP_MASK      = 0x1fe00000,  /* Mask for flags set by the app layer */
 	/* unused             0x20000000,*/
 	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 */
 };
 
 /* stconn flags */
diff --git a/include/haproxy/cs_utils.h b/include/haproxy/cs_utils.h
index 9aceb9c..0da4f43 100644
--- a/include/haproxy/cs_utils.h
+++ b/include/haproxy/cs_utils.h
@@ -296,13 +296,15 @@
 {
 	struct channel *ic = sc_ic(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))
+	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;
 
-	if (cs_rx_blocked(cs) || !cs_rx_endp_ready(cs))
+	if (sc_ep_test(cs, SE_FL_APPLET_NEED_CONN) ||
+	    cs_rx_blocked(cs) || !cs_rx_endp_ready(cs))
 		return;
 
 	if (!cs_state_in(cs->state, SC_SB_RDY|SC_SB_EST))
diff --git a/src/conn_stream.c b/src/conn_stream.c
index 85c3b82..b60a9c5 100644
--- a/src/conn_stream.c
+++ b/src/conn_stream.c
@@ -1178,7 +1178,7 @@
 	cs_chk_rcv(cs);
 	cs_chk_rcv(cso);
 
-	if (ic->flags & CF_SHUTR || cs_rx_blocked(cs)) {
+	if (ic->flags & CF_SHUTR || sc_ep_test(cs, SE_FL_APPLET_NEED_CONN) || cs_rx_blocked(cs)) {
 		ic->rex = TICK_ETERNITY;
 	}
 	else if ((ic->flags & (CF_SHUTR|CF_READ_PARTIAL)) == CF_READ_PARTIAL) {
@@ -1925,7 +1925,7 @@
 	/* automatically mark the applet having data available if it reported
 	 * begin blocked by the channel.
 	 */
-	if (cs_rx_blocked(cs))
+	if (cs_rx_blocked(cs) || sc_ep_test(cs, SE_FL_APPLET_NEED_CONN))
 		cs_rx_endp_more(cs);
 
 	/* update the stream connector, channels, and possibly wake the stream up */
@@ -1937,7 +1937,8 @@
 	 * appctx but in the case the task is not in runqueue we may have to
 	 * wakeup the appctx immediately.
 	 */
-	if ((cs_rx_endp_ready(cs) && !cs_rx_blocked(cs) && !(ic->flags & CF_SHUTR)) ||
+	if ((cs_rx_endp_ready(cs) && !cs_rx_blocked(cs) &&
+	     !sc_ep_test(cs, SE_FL_APPLET_NEED_CONN) && !(ic->flags & CF_SHUTR)) ||
 	    sc_is_send_allowed(cs))
 		appctx_wakeup(__sc_appctx(cs));
 	return 0;
diff --git a/src/stream.c b/src/stream.c
index 606a868..1a28900 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -1543,11 +1543,13 @@
 	 * handled at the latest moment.
 	 */
 	if (sc_appctx(scf)) {
-		if ((cs_rx_endp_ready(scf) && !cs_rx_blocked(scf) && !(req->flags & CF_SHUTR)) || sc_is_send_allowed(scf))
+		if ((cs_rx_endp_ready(scf) && !cs_rx_blocked(scf) && !sc_ep_test(scf, SE_FL_APPLET_NEED_CONN) &&
+		     !(req->flags & CF_SHUTR)) || sc_is_send_allowed(scf))
 			appctx_wakeup(__sc_appctx(scf));
 	}
 	if (sc_appctx(scb)) {
-		if ((cs_rx_endp_ready(scb) && !cs_rx_blocked(scb) && !(res->flags & CF_SHUTR)) || sc_is_send_allowed(scb))
+		if ((cs_rx_endp_ready(scb) && !cs_rx_blocked(scb) && !sc_ep_test(scb, SE_FL_APPLET_NEED_CONN) &&
+		     !(res->flags & CF_SHUTR)) || sc_is_send_allowed(scb))
 			appctx_wakeup(__sc_appctx(scb));
 	}
 }