MINOR: stconn/channel: Move CF_EOI into the SC and rename it

The channel flag CF_EOI is renamed to SC_FL_EOI and moved into the
stream-connector.
diff --git a/include/haproxy/channel-t.h b/include/haproxy/channel-t.h
index a69ce46..32f6983 100644
--- a/include/haproxy/channel-t.h
+++ b/include/haproxy/channel-t.h
@@ -114,7 +114,7 @@
 
 #define CF_WAKE_ONCE      0x10000000  /* pretend there is activity on this channel (one-shoot) */
 #define CF_FLT_ANALYZE    0x20000000  /* at least one filter is still analyzing this channel */
-#define CF_EOI            0x40000000  /* end-of-input has been reached */
+/* unuse 0x40000000 */
 #define CF_ISRESP         0x80000000  /* 0 = request channel, 1 = response channel */
 
 /* Masks which define input events for stream analysers */
@@ -141,7 +141,7 @@
 	_(CF_KERN_SPLICING,
 	_(CF_AUTO_CONNECT, _(CF_DONT_READ,
 	_(CF_WAKE_ONCE, _(CF_FLT_ANALYZE,
-	_(CF_EOI, _(CF_ISRESP))))))))))))))))))));
+	_(CF_ISRESP)))))))))))))))))));
 	/* epilogue */
 	_(~0U);
 	return buf;
diff --git a/include/haproxy/sc_strm.h b/include/haproxy/sc_strm.h
index 5794092..199e8d2 100644
--- a/include/haproxy/sc_strm.h
+++ b/include/haproxy/sc_strm.h
@@ -375,9 +375,9 @@
 
 static inline int sc_rcv_may_expire(const struct stconn *sc)
 {
-	if (sc_ic(sc)->flags & (CF_EOI|CF_SHUTR|CF_READ_TIMEOUT|CF_READ_EVENT))
+	if (sc_ic(sc)->flags & (CF_SHUTR|CF_READ_TIMEOUT|CF_READ_EVENT))
 		return 0;
-	if (sc->flags & (SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM))
+	if (sc->flags & (SC_FL_EOI|SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM))
 		return 0;
 	if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN) || sc_ep_test(sc_opposite(sc), SE_FL_EXP_NO_DATA))
 		return 0;
diff --git a/include/haproxy/stconn-t.h b/include/haproxy/stconn-t.h
index 285b35c..e97bf83 100644
--- a/include/haproxy/stconn-t.h
+++ b/include/haproxy/stconn-t.h
@@ -114,7 +114,7 @@
 	SC_FL_NONE          = 0x00000000,  /* Just for initialization purposes */
 	SC_FL_ISBACK        = 0x00000001,  /* Set for SC on back-side */
 
-	/* not used: 0x00000002 */
+	SC_FL_EOI           = 0x00000002,  /* End of input was reached. no more data will be received from the endpoint */
 	/* not used: 0x00000004 */
 
 	SC_FL_NOLINGER      = 0x00000008,  /* may close without lingering. One-shot. */
@@ -142,10 +142,10 @@
 	/* prologue */
 	_(0);
 	/* flags */
-	_(SC_FL_ISBACK, _(SC_FL_NOLINGER, _(SC_FL_NOHALF,
+	_(SC_FL_ISBACK, _(SC_FL_EOI, _(SC_FL_NOLINGER, _(SC_FL_NOHALF,
 	_(SC_FL_DONT_WAKE, _(SC_FL_INDEP_STR, _(SC_FL_WONT_READ,
 	_(SC_FL_NEED_BUFF, _(SC_FL_NEED_ROOM,
-	_(SC_FL_RCV_ONCE, _(SC_FL_SND_ASAP, _(SC_FL_SND_NEVERWAIT, _(SC_FL_SND_EXP_MORE))))))))))));
+	_(SC_FL_RCV_ONCE, _(SC_FL_SND_ASAP, _(SC_FL_SND_NEVERWAIT, _(SC_FL_SND_EXP_MORE)))))))))))));
 	/* epilogue */
 	_(~0U);
 	return buf;
diff --git a/src/backend.c b/src/backend.c
index d022627..af39fef 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1848,8 +1848,10 @@
 	 *       wake callback. Otherwise si_cs_recv()/si_cs_send() already take
 	 *       care of it.
 	 */
-	if (sc_ep_test(s->scb, SE_FL_EOI) && !(sc_ic(s->scb)->flags & CF_EOI))
-		sc_ic(s->scb)->flags |= (CF_EOI|CF_READ_EVENT);
+	if (sc_ep_test(s->scb, SE_FL_EOI) && !(s->scb->flags & SC_FL_EOI)) {
+		s->scb->flags |= SC_FL_EOI;
+		sc_ic(s->scb)->flags |= CF_READ_EVENT;
+	}
 
 	/* catch all sync connect while the mux is not already installed */
 	if (!srv_conn->mux && !(srv_conn->flags & CO_FL_WAIT_XPRT)) {
diff --git a/src/flt_bwlim.c b/src/flt_bwlim.c
index 20919fc..e14b774 100644
--- a/src/flt_bwlim.c
+++ b/src/flt_bwlim.c
@@ -151,7 +151,7 @@
 		 */
 		ret = tokens;
 		if (tokens < conf->min_size) {
-			ret = (chn->flags & (CF_EOI|CF_SHUTR))
+			ret = ((chn_prod(chn)->flags & SC_FL_EOI) || (chn->flags & CF_SHUTR))
 				? MIN(len, conf->min_size)
 				: conf->min_size;
 
diff --git a/src/hlua.c b/src/hlua.c
index 5a0a78c..f2e6f24 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -5106,7 +5106,7 @@
 	/* The message was fully consumed and no more data are expected
 	 * (EOM flag set).
 	 */
-	if (htx_is_empty(htx) && (req->flags & CF_EOI))
+	if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI))
 		stop = 1;
 
 	htx_to_buf(htx, &req->buf);
@@ -5198,7 +5198,7 @@
 	/* The message was fully consumed and no more data are expected
 	 * (EOM flag set).
 	 */
-	if (htx_is_empty(htx) && (req->flags & CF_EOI))
+	if (htx_is_empty(htx) && (sc->flags & SC_FL_EOI))
 		len = 0;
 
 	htx_to_buf(htx, &req->buf);
diff --git a/src/http_ana.c b/src/http_ana.c
index ae97b33..6a309c7 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -911,7 +911,7 @@
 
 	if (req->to_forward) {
 		if (req->to_forward == CHN_INFINITE_FORWARD) {
-			if (req->flags & CF_EOI)
+			if (s->scf->flags & SC_FL_EOI)
 				msg->msg_state = HTTP_MSG_ENDING;
 		}
 		else {
@@ -1134,7 +1134,7 @@
 	res = &s->res;
 	/* Remove any write error from the request, and read error from the response */
 	req->flags &= ~(CF_WRITE_TIMEOUT | CF_SHUTW | CF_SHUTW_NOW);
-	res->flags &= ~(CF_READ_TIMEOUT | CF_SHUTR | CF_EOI | CF_READ_EVENT | CF_SHUTR_NOW);
+	res->flags &= ~(CF_READ_TIMEOUT | CF_SHUTR | CF_READ_EVENT | CF_SHUTR_NOW);
 	res->analysers &= AN_RES_FLT_END;
 	s->conn_err_type = STRM_ET_NONE;
 	s->flags &= ~(SF_CONN_EXP | SF_ERR_MASK | SF_FINST_MASK);
@@ -2019,7 +2019,7 @@
 
 	if (res->to_forward) {
 		if (res->to_forward == CHN_INFINITE_FORWARD) {
-			if (res->flags & CF_EOI)
+			if (s->scb->flags & SC_FL_EOI)
 				msg->msg_state = HTTP_MSG_ENDING;
 		}
 		else {
@@ -4449,11 +4449,11 @@
 		channel_auto_read(res);
 		channel_auto_close(res);
 		channel_shutr_now(res);
-		res->flags |= CF_EOI; /* The response is terminated, add EOI */
+		s->scb->flags |= SC_FL_EOI; /* The response is terminated, add EOI */
 		htxbuf(&res->buf)->flags |= HTX_FL_EOM; /* no more data are expected */
 	}
 	else {
-		/* Send ASAP informational messages. Rely on CF_EOI for final
+		/* Send ASAP informational messages. Rely on SC_FL_EOI for final
 		 * response.
 		 */
 		s->scf->flags |= SC_FL_SND_ASAP;
diff --git a/src/http_fetch.c b/src/http_fetch.c
index 1775bc6..2485eb3 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -615,7 +615,7 @@
 	smp->flags = SMP_F_VOL_TEST;
 
 	if (!finished && (check || (chn && !channel_full(chn, global.tune.maxrewrite) &&
-				    !(chn->flags & (CF_EOI|CF_SHUTR)))))
+				    !(chn_prod(chn)->flags & SC_FL_EOI) && !(chn->flags & CF_SHUTR))))
 		smp->flags |= SMP_F_MAY_CHANGE;
 
 	return 1;
diff --git a/src/stconn.c b/src/stconn.c
index 1e2ca26..d1aa1b5 100644
--- a/src/stconn.c
+++ b/src/stconn.c
@@ -1096,11 +1096,11 @@
 	if (/* changes on the production side that must be handled:
 	     *  - An error on receipt: SE_FL_ERROR
 	     *  - A read event: shutdown for reads (CF_READ_EVENT + SHUTR)
-	     *                  end of input (CF_READ_EVENT + CF_EOI)
+	     *                  end of input (CF_READ_EVENT + SC_FL_EOI)
 	     *                  data received and no fast-forwarding (CF_READ_EVENT + !to_forward)
 	     *                  read event while consumer side is not established (CF_READ_EVENT + sco->state != SC_ST_EST)
 	     */
-	    ((ic->flags & CF_READ_EVENT) && ((ic->flags & (CF_SHUTR|CF_EOI)) || !ic->to_forward || sco->state != SC_ST_EST)) ||
+		((ic->flags & CF_READ_EVENT) && ((sc->flags & SC_FL_EOI) || (ic->flags & CF_SHUTR) || !ic->to_forward || sco->state != SC_ST_EST)) ||
 	    sc_ep_test(sc, SE_FL_ERROR) ||
 
 	    /* changes on the consumption side */
@@ -1466,9 +1466,10 @@
 
 	/* Report EOI on the channel if it was reached from the mux point of
 	 * view. */
-	if (sc_ep_test(sc, SE_FL_EOI) && !(ic->flags & CF_EOI)) {
+	if (sc_ep_test(sc, SE_FL_EOI) && !(sc->flags & SC_FL_EOI)) {
 		sc_ep_report_read_activity(sc);
-		ic->flags |= (CF_EOI|CF_READ_EVENT);
+		sc->flags |= SC_FL_EOI;
+		ic->flags |= CF_READ_EVENT;
 		ret = 1;
 	}
 
@@ -1528,6 +1529,7 @@
 static int sc_conn_send(struct stconn *sc)
 {
 	struct connection *conn = __sc_conn(sc);
+	struct stconn *sco = sc_opposite(sc);
 	struct stream *s = __sc_strm(sc);
 	struct channel *oc = sc_oc(sc);
 	int ret;
@@ -1597,7 +1599,7 @@
 		     ((oc->to_forward && oc->to_forward != CHN_INFINITE_FORWARD) ||
 		      (sc->flags & SC_FL_SND_EXP_MORE) ||
 		      (IS_HTX_STRM(s) &&
-		       (!(oc->flags & (CF_EOI|CF_SHUTR)) && htx_expect_more(htxbuf(&oc->buf)))))) ||
+		       (!(sco->flags & SC_FL_EOI) && !(oc->flags & CF_SHUTR) && htx_expect_more(htxbuf(&oc->buf)))))) ||
 		    ((oc->flags & CF_ISRESP) &&
 		     ((oc->flags & (CF_AUTO_CLOSE|CF_SHUTW_NOW)) == (CF_AUTO_CLOSE|CF_SHUTW_NOW))))
 			send_flag |= CO_SFL_MSG_MORE;
@@ -1775,8 +1777,10 @@
 	 *       wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take
 	 *       care of it.
 	 */
-	if (sc_ep_test(sc, SE_FL_EOI) && !(ic->flags & CF_EOI))
-		ic->flags |= (CF_EOI|CF_READ_EVENT);
+	if (sc_ep_test(sc, SE_FL_EOI) && !(sc->flags & SC_FL_EOI)) {
+		sc->flags |= SC_FL_EOI;
+		ic->flags |= CF_READ_EVENT;
+	}
 
 	/* Second step : update the stream connector and channels, try to forward any
 	 * pending data, then possibly wake the stream up based on the new
@@ -1824,9 +1828,10 @@
 
 	/* Report EOI on the channel if it was reached from the applet point of
 	 * view. */
-	if (sc_ep_test(sc, SE_FL_EOI) && !(ic->flags & CF_EOI)) {
+	if (sc_ep_test(sc, SE_FL_EOI) && !(sc->flags & SC_FL_EOI)) {
 		sc_ep_report_read_activity(sc);
-		ic->flags |= (CF_EOI|CF_READ_EVENT);
+		sc->flags |= SC_FL_EOI;
+		ic->flags |= CF_READ_EVENT;
 	}
 
 	if (sc_ep_test(sc, SE_FL_EOS)) {
diff --git a/src/tcp_rules.c b/src/tcp_rules.c
index 1d1ce7d..bb4e51f 100644
--- a/src/tcp_rules.c
+++ b/src/tcp_rules.c
@@ -116,7 +116,7 @@
 	 * - if one rule returns KO, then return KO
 	 */
 
-	if ((req->flags & (CF_EOI|CF_SHUTR)) || channel_full(req, global.tune.maxrewrite) ||
+	if ((s->scf->flags & SC_FL_EOI) || (req->flags & CF_SHUTR) || channel_full(req, global.tune.maxrewrite) ||
 	    sc_waiting_room(chn_prod(req)) ||
 	    !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) {
 		partial = SMP_OPT_FINAL;
@@ -299,7 +299,7 @@
 	 * - if one rule returns OK, then return OK
 	 * - if one rule returns KO, then return KO
 	 */
-	if ((rep->flags & (CF_EOI|CF_SHUTR)) || channel_full(rep, global.tune.maxrewrite) ||
+	if ((s->scb->flags & SC_FL_EOI) || (rep->flags & CF_SHUTR) || channel_full(rep, global.tune.maxrewrite) ||
 	    sc_waiting_room(chn_prod(rep)) ||
 	    !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) {
 		partial = SMP_OPT_FINAL;