MINOR: tree-wide: Simplifiy some tests on SHUT flags by accessing SCs directly

At many places, we simplify the tests on SHUT flags to remove calls to
chn_prod() or chn_cons() function because the corresponding SC is available.
diff --git a/include/haproxy/sc_strm.h b/include/haproxy/sc_strm.h
index fbe0968..1161f53 100644
--- a/include/haproxy/sc_strm.h
+++ b/include/haproxy/sc_strm.h
@@ -286,9 +286,7 @@
 __attribute__((warn_unused_result))
 static inline int sc_is_recv_allowed(const struct stconn *sc)
 {
-	struct channel *ic = sc_ic(sc);
-
-	if (chn_prod(ic)->flags & SC_FL_SHUTR)
+	if (sc->flags & SC_FL_SHUTR)
 		return 0;
 
 	if (sc_ep_test(sc, SE_FL_APPLET_NEED_CONN))
@@ -365,9 +363,7 @@
 __attribute__((warn_unused_result))
 static inline int sc_is_send_allowed(const struct stconn *sc)
 {
-	struct channel *oc = sc_oc(sc);
-
-	if (chn_cons(oc)->flags & SC_FL_SHUTW)
+	if (sc->flags & SC_FL_SHUTW)
 		return 0;
 
 	return !sc_ep_test(sc, SE_FL_WAIT_DATA | SE_FL_WONT_CONSUME);
@@ -375,8 +371,8 @@
 
 static inline int sc_rcv_may_expire(const struct stconn *sc)
 {
-	if ((chn_prod(sc_ic(sc))->flags & SC_FL_SHUTR) ||
-	     (sc_ic(sc)->flags & (CF_READ_TIMEOUT|CF_READ_EVENT)))
+	if ((sc->flags & SC_FL_SHUTR) ||
+	    (sc_ic(sc)->flags & (CF_READ_TIMEOUT|CF_READ_EVENT)))
 		return 0;
 	if (sc->flags & (SC_FL_EOI|SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM))
 		return 0;
@@ -387,7 +383,7 @@
 
 static inline int sc_snd_may_expire(const struct stconn *sc)
 {
-	if ((chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW) ||
+	if ((sc->flags & SC_FL_SHUTW) ||
 	    (sc_oc(sc)->flags & (CF_WRITE_TIMEOUT|CF_WRITE_EVENT)))
 		return 0;
 	if (sc_ep_test(sc, SE_FL_WONT_CONSUME))
diff --git a/src/activity.c b/src/activity.c
index bfdd6f3..9d396cd 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -625,7 +625,7 @@
 	int i, j, max;
 
 	/* FIXME: Don't watch the other side ! */
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	chunk_reset(&trash);
@@ -889,7 +889,7 @@
 	int i, max;
 
 	/* FIXME: Don't watch the other side ! */
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	/* It's not possible to scan queues in small chunks and yield in the
@@ -1030,7 +1030,7 @@
 	int thr;
 
 	/* FIXME: Don't watch the other side ! */
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	chunk_reset(&trash);
diff --git a/src/applet.c b/src/applet.c
index 0c5b40d..b9bb992 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -471,7 +471,7 @@
 	     (b_size(sc_ib(sc)) && !b_data(sc_ib(sc)) && sc->flags & SC_FL_NEED_ROOM) || // asks for room in an empty buffer
 	     (b_data(sc_ob(sc)) && sc_is_send_allowed(sc)) || // asks for data already present
 	     (!b_data(sc_ib(sc)) && b_data(sc_ob(sc)) && // didn't return anything ...
-	      (!(sc_oc(sc)->flags & CF_WRITE_EVENT) && (chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW_NOW))))) { // ... and left data pending after a shut
+	      (!(sc_oc(sc)->flags & CF_WRITE_EVENT) && (sc->flags & SC_FL_SHUTW_NOW))))) { // ... and left data pending after a shut
 		rate = update_freq_ctr(&app->call_rate, 1);
 		if (rate >= 100000 && app->call_rate.prev_ctr) // looped like this more than 100k times over last second
 			stream_dump_and_crash(&app->obj_type, read_freq_ctr(&app->call_rate));
diff --git a/src/cli.c b/src/cli.c
index 21d6620..1b4276f 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1214,7 +1214,7 @@
 	char **var = ctx->var;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	chunk_reset(&trash);
@@ -1253,7 +1253,7 @@
 	int ret = 1;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		goto end;
 
 	chunk_reset(&trash);
diff --git a/src/debug.c b/src/debug.c
index 5209166..ed7f971 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -314,7 +314,7 @@
 	int thr;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	if (appctx->st0)
@@ -1162,7 +1162,7 @@
 	int i, fd;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		goto end;
 
 	chunk_reset(&trash);
@@ -1370,7 +1370,7 @@
 	int ret = 1;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		goto end;
 
 	if (!ctx->width) {
diff --git a/src/map.c b/src/map.c
index ff6bbf5..b7e087b 100644
--- a/src/map.c
+++ b/src/map.c
@@ -349,7 +349,7 @@
 	struct pat_ref_elt *elt;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW)) {
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW)) {
 		/* If we're forced to shut down, we might have to remove our
 		 * reference to the last ref_elt being dumped.
 		 */
diff --git a/src/mworker.c b/src/mworker.c
index 17609f6..7b4f09c 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -568,7 +568,7 @@
 	char *reloadtxt = NULL;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	if (up < 0) /* must never be negative because of clock drift */
@@ -715,7 +715,7 @@
 		return 1;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	env = getenv("HAPROXY_LOAD_SUCCESS");
diff --git a/src/proxy.c b/src/proxy.c
index 276228c..89c9cbe 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -3209,7 +3209,7 @@
 	extern const char *monthname[12];
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	chunk_reset(&trash);
diff --git a/src/quic_conn.c b/src/quic_conn.c
index a09216e..d858b43 100644
--- a/src/quic_conn.c
+++ b/src/quic_conn.c
@@ -8262,7 +8262,7 @@
 		goto done;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW)) {
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW)) {
 		/* If we're forced to shut down, we might have to remove our
 		 * reference to the last stream being dumped.
 		 */
diff --git a/src/ring.c b/src/ring.c
index 6d75f05..fbd2d06 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -350,7 +350,7 @@
 	int ret;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		return 1;
 
 	HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
@@ -423,7 +423,7 @@
 		/* we've drained everything and are configured to wait for more
 		 * data or an event (keypress, close)
 		 */
-		if (!sc_oc(sc)->output && !(chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW)) {
+		if (!sc_oc(sc)->output && !(sc->flags & SC_FL_SHUTW)) {
 			/* let's be woken up once new data arrive */
 			HA_RWLOCK_WRLOCK(LOGSRV_LOCK, &ring->lock);
 			LIST_APPEND(&ring->waiters, &appctx->wait_entry);
diff --git a/src/ssl_ckch.c b/src/ssl_ckch.c
index bfb4235..5b3a20d 100644
--- a/src/ssl_ckch.c
+++ b/src/ssl_ckch.c
@@ -2149,7 +2149,7 @@
 	struct ckch_inst *ckchi;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		goto end;
 
 	while (1) {
@@ -2826,7 +2826,7 @@
 	char *path;
 
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		goto end;
 
 	/* The ctx was already validated by the ca-file/crl-file parsing
diff --git a/src/ssl_crtlist.c b/src/ssl_crtlist.c
index 7b410e9..f74f43a 100644
--- a/src/ssl_crtlist.c
+++ b/src/ssl_crtlist.c
@@ -1117,7 +1117,7 @@
 	 * created.
 	 */
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW))
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW))
 		goto end;
 
 	switch (ctx->state) {
diff --git a/src/stconn.c b/src/stconn.c
index 5d94646..061a003 100644
--- a/src/stconn.c
+++ b/src/stconn.c
@@ -507,7 +507,7 @@
 static inline int sc_cond_forward_shutw(struct stconn *sc)
 {
 	/* The close must not be forwarded */
-	if (!(chn_prod(sc_ic(sc))->flags & SC_FL_SHUTR) || !(sc->flags & SC_FL_NOHALF))
+	if (!(sc->flags & SC_FL_SHUTR) || !(sc->flags & SC_FL_NOHALF))
 		return 0;
 
 	if (!channel_is_empty(sc_ic(sc))) {
@@ -534,17 +534,17 @@
 {
 	struct channel *ic = sc_ic(sc);
 
-	if (chn_prod(ic)->flags & SC_FL_SHUTR)
+	if (sc->flags & SC_FL_SHUTR)
 		return;
 
-	chn_prod(ic)->flags |= SC_FL_SHUTR;
+	sc->flags |= SC_FL_SHUTR;
 	ic->flags |= CF_READ_EVENT;
 	sc_ep_report_read_activity(sc);
 
 	if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
 		return;
 
-	if (chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW) {
+	if (sc->flags & SC_FL_SHUTW) {
 		sc->state = SC_ST_DIS;
 		if (sc->flags & SC_FL_ISBACK)
 			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
@@ -569,10 +569,10 @@
 	struct channel *ic = sc_ic(sc);
 	struct channel *oc = sc_oc(sc);
 
-	chn_cons(oc)->flags &= ~SC_FL_SHUTW_NOW;
-	if (chn_cons(oc)->flags & SC_FL_SHUTW)
+	sc->flags &= ~SC_FL_SHUTW_NOW;
+	if (sc->flags & SC_FL_SHUTW)
 		return;
-	chn_cons(oc)->flags |= SC_FL_SHUTW;
+	sc->flags |= SC_FL_SHUTW;
 	oc->flags |= CF_WRITE_EVENT;
 	sc_set_hcto(sc);
 
@@ -586,7 +586,7 @@
 		 * no risk so we close both sides immediately.
 		 */
 		if (!sc_ep_test(sc, SE_FL_ERROR) && !(sc->flags & SC_FL_NOLINGER) &&
-		    !(chn_prod(ic)->flags & SC_FL_SHUTR) && !(ic->flags & CF_DONT_READ))
+		    !(sc->flags & SC_FL_SHUTR) && !(ic->flags & CF_DONT_READ))
 			return;
 
 		__fallthrough;
@@ -599,7 +599,7 @@
 		__fallthrough;
 	default:
 		sc->flags &= ~SC_FL_NOLINGER;
-		chn_prod(ic)->flags |= SC_FL_SHUTR;
+		sc->flags |= SC_FL_SHUTR;
 		if (sc->flags & SC_FL_ISBACK)
 			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
@@ -630,7 +630,7 @@
 {
 	struct channel *oc = sc_oc(sc);
 
-	if (unlikely(sc->state != SC_ST_EST || (chn_cons(oc)->flags & SC_FL_SHUTW)))
+	if (unlikely(sc->state != SC_ST_EST || (sc->flags & SC_FL_SHUTW)))
 		return;
 
 	if (!sc_ep_test(sc, SE_FL_WAIT_DATA) ||  /* not waiting for data */
@@ -661,15 +661,15 @@
 
 	BUG_ON(!sc_conn(sc));
 
-	if (chn_prod(ic)->flags & SC_FL_SHUTR)
+	if (sc->flags & SC_FL_SHUTR)
 		return;
-	chn_prod(ic)->flags |= SC_FL_SHUTR;
+	sc->flags |= SC_FL_SHUTR;
 	ic->flags |= CF_READ_EVENT;
 
 	if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
 		return;
 
-	if (chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW) {
+	if (sc->flags & SC_FL_SHUTW) {
 		sc_conn_shut(sc);
 		sc->state = SC_ST_DIS;
 		if (sc->flags & SC_FL_ISBACK)
@@ -694,10 +694,10 @@
 
 	BUG_ON(!sc_conn(sc));
 
-	chn_cons(oc)->flags &= ~SC_FL_SHUTW_NOW;
-	if (chn_cons(oc)->flags & SC_FL_SHUTW)
+	sc->flags &= ~SC_FL_SHUTW_NOW;
+	if (sc->flags & SC_FL_SHUTW)
 		return;
-	chn_cons(oc)->flags |= SC_FL_SHUTW;
+	sc->flags |= SC_FL_SHUTW;
 	oc->flags |= CF_WRITE_EVENT;
 	sc_set_hcto(sc);
 
@@ -731,7 +731,7 @@
 			 */
 			sc_conn_shutw(sc, CO_SHW_NORMAL);
 
-			if (!(chn_prod(ic)->flags & SC_FL_SHUTR) && !(ic->flags & CF_DONT_READ))
+			if (!(sc->flags & SC_FL_SHUTR) && !(ic->flags & CF_DONT_READ))
 				return;
 		}
 
@@ -749,7 +749,7 @@
 		__fallthrough;
 	default:
 		sc->flags &= ~SC_FL_NOLINGER;
-		chn_prod(ic)->flags |= SC_FL_SHUTR;
+		sc->flags |= SC_FL_SHUTR;
 		if (sc->flags & SC_FL_ISBACK)
 			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
@@ -783,7 +783,7 @@
 	BUG_ON(!sc_conn(sc));
 
 	if (unlikely(!sc_state_in(sc->state, SC_SB_RDY|SC_SB_EST) ||
-		     (chn_cons(oc)->flags & SC_FL_SHUTW)))
+		     (sc->flags & SC_FL_SHUTW)))
 		return;
 
 	if (unlikely(channel_is_empty(oc)))  /* called with nothing to send ! */
@@ -813,13 +813,13 @@
 		 * chunk and need to close.
 		 */
 		if ((oc->flags & CF_AUTO_CLOSE) &&
-		    ((chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW) &&
+		    ((sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW) &&
 		    sc_state_in(sc->state, SC_SB_RDY|SC_SB_EST)) {
 			sc_shutw(sc);
 			goto out_wakeup;
 		}
 
-		if ((chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == 0)
+		if ((sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == 0)
 			sc_ep_set(sc, SE_FL_WAIT_DATA);
 	}
 	else {
@@ -832,7 +832,7 @@
 	/* in case of special condition (error, shutdown, end of write...), we
 	 * have to notify the task.
 	 */
-	if (likely((chn_cons(oc)->flags & SC_FL_SHUTW) ||
+	if (likely((sc->flags & SC_FL_SHUTW) ||
 		   ((oc->flags & CF_WRITE_EVENT) && sc->state < SC_ST_EST) ||
 		   ((oc->flags & CF_WAKE_WRITE) &&
 		    ((channel_is_empty(oc) && !oc->to_forward) ||
@@ -857,9 +857,9 @@
 
 	BUG_ON(!sc_appctx(sc));
 
-	if (chn_prod(ic)->flags & SC_FL_SHUTR)
+	if (sc->flags & SC_FL_SHUTR)
 		return;
-	chn_prod(ic)->flags |= SC_FL_SHUTR;
+	sc->flags |= SC_FL_SHUTR;
 	ic->flags |= CF_READ_EVENT;
 
 	/* Note: on shutr, we don't call the applet */
@@ -867,7 +867,7 @@
 	if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
 		return;
 
-	if (chn_cons(sc_oc(sc))->flags & SC_FL_SHUTW) {
+	if (sc->flags & SC_FL_SHUTW) {
 		appctx_shut(__sc_appctx(sc));
 		sc->state = SC_ST_DIS;
 		if (sc->flags & SC_FL_ISBACK)
@@ -891,10 +891,10 @@
 
 	BUG_ON(!sc_appctx(sc));
 
-	chn_cons(oc)->flags &= ~SC_FL_SHUTW_NOW;
-	if (chn_cons(oc)->flags & SC_FL_SHUTW)
+	sc->flags &= ~SC_FL_SHUTW_NOW;
+	if (sc->flags & SC_FL_SHUTW)
 		return;
-	chn_cons(oc)->flags |= SC_FL_SHUTW;
+	sc->flags |= SC_FL_SHUTW;
 	oc->flags |= CF_WRITE_EVENT;
 	sc_set_hcto(sc);
 
@@ -911,7 +911,7 @@
 		 * no risk so we close both sides immediately.
 		 */
 		if (!sc_ep_test(sc, SE_FL_ERROR) && !(sc->flags & SC_FL_NOLINGER) &&
-		    !(chn_prod(ic)->flags & SC_FL_SHUTR) &&
+		    !(sc->flags & SC_FL_SHUTR) &&
 		    !(ic->flags & CF_DONT_READ))
 			return;
 
@@ -926,7 +926,7 @@
 		__fallthrough;
 	default:
 		sc->flags &= ~SC_FL_NOLINGER;
-		chn_prod(ic)->flags |= SC_FL_SHUTR;
+		sc->flags |= SC_FL_SHUTR;
 		if (sc->flags & SC_FL_ISBACK)
 			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
@@ -952,7 +952,7 @@
 
 	BUG_ON(!sc_appctx(sc));
 
-	if (unlikely(sc->state != SC_ST_EST || (chn_cons(oc)->flags & SC_FL_SHUTW)))
+	if (unlikely(sc->state != SC_ST_EST || (sc->flags & SC_FL_SHUTW)))
 		return;
 
 	/* we only wake the applet up if it was waiting for some data  and is ready to consume it */
@@ -979,7 +979,7 @@
 {
 	struct channel *ic = sc_ic(sc);
 
-	if (chn_prod(ic)->flags & SC_FL_SHUTR)
+	if (sc->flags & SC_FL_SHUTR)
 		return;
 
 	/* Read not closed, update FD status and timeout for reads */
@@ -1004,14 +1004,14 @@
 {
 	struct channel *oc = sc_oc(sc);
 
-	if (chn_cons(oc)->flags & SC_FL_SHUTW)
+	if (sc->flags & SC_FL_SHUTW)
 		return;
 
 	/* Write not closed, update FD status and timeout for writes */
 	if (channel_is_empty(oc)) {
 		/* stop writing */
 		if (!sc_ep_test(sc, SE_FL_WAIT_DATA)) {
-			if ((chn_cons(oc)->flags & SC_FL_SHUTW_NOW) == 0)
+			if ((sc->flags & SC_FL_SHUTW_NOW) == 0)
 				sc_ep_set(sc, SE_FL_WAIT_DATA);
 		}
 		return;
@@ -1042,7 +1042,7 @@
 	if (channel_is_empty(oc)) {
 		struct connection *conn = sc_conn(sc);
 
-		if (((chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW) &&
+		if (((sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW) &&
 		    (sc->state == SC_ST_EST) && (!conn || !(conn->flags & (CO_FL_WAIT_XPRT | CO_FL_EARLY_SSL_HS))))
 			sc_shutw(sc);
 	}
@@ -1050,9 +1050,9 @@
 	/* indicate that we may be waiting for data from the output channel or
 	 * we're about to close and can't expect more data if SC_FL_SHUTW_NOW is there.
 	 */
-	if (!(chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)))
+	if (!(sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)))
 		sc_ep_set(sc, SE_FL_WAIT_DATA);
-	else if ((chn_cons(oc)->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW)
+	else if ((sc->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) == SC_FL_SHUTW_NOW)
 		sc_ep_clr(sc, SE_FL_WAIT_DATA);
 
 	if (oc->flags & CF_DONT_READ)
@@ -1108,17 +1108,17 @@
 	     *                  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) && ((sc->flags & SC_FL_EOI) || (chn_prod(ic)->flags & SC_FL_SHUTR) || !ic->to_forward || sco->state != SC_ST_EST)) ||
+		((ic->flags & CF_READ_EVENT) && ((sc->flags & SC_FL_EOI) || (sc->flags & SC_FL_SHUTR) || !ic->to_forward || sco->state != SC_ST_EST)) ||
 	    sc_ep_test(sc, SE_FL_ERROR) ||
 
 	    /* changes on the consumption side */
 	    sc_ep_test(sc, SE_FL_ERR_PENDING) ||
 	    ((oc->flags & CF_WRITE_EVENT) &&
 	     ((sc->state < SC_ST_EST) ||
-	      (chn_cons(oc)->flags & SC_FL_SHUTW) ||
+	      (sc->flags & SC_FL_SHUTW) ||
 	      (((oc->flags & CF_WAKE_WRITE) ||
 		(!(oc->flags & CF_AUTO_CLOSE) &&
-		 !(chn_cons(oc)->flags & (SC_FL_SHUTW_NOW|SC_FL_SHUTW)))) &&
+		 !(sc->flags & (SC_FL_SHUTW_NOW|SC_FL_SHUTW)))) &&
 	       (sco->state != SC_ST_EST ||
 		(channel_is_empty(oc) && !oc->to_forward)))))) {
 		task_wakeup(task, TASK_WOKEN_IO);
@@ -1136,20 +1136,19 @@
 static void sc_conn_read0(struct stconn *sc)
 {
 	struct channel *ic = sc_ic(sc);
-	struct channel *oc = sc_oc(sc);
 
 	BUG_ON(!sc_conn(sc));
 
-	if (chn_prod(ic)->flags & SC_FL_SHUTR)
+	if (sc->flags & SC_FL_SHUTR)
 		return;
-	chn_prod(ic)->flags |= SC_FL_SHUTR;
+	sc->flags |= SC_FL_SHUTR;
 	ic->flags |= CF_READ_EVENT;
 	sc_ep_report_read_activity(sc);
 
 	if (!sc_state_in(sc->state, SC_SB_CON|SC_SB_RDY|SC_SB_EST))
 		return;
 
-	if (chn_cons(oc)->flags & SC_FL_SHUTW)
+	if (sc->flags & SC_FL_SHUTW)
 		goto do_close;
 
 	if (sc_cond_forward_shutw(sc)) {
@@ -1166,8 +1165,8 @@
 	/* OK we completely close the socket here just as if we went through sc_shut[rw]() */
 	sc_conn_shut(sc);
 
-	chn_cons(oc)->flags &= ~SC_FL_SHUTW_NOW;
-	chn_cons(oc)->flags |= SC_FL_SHUTW;
+	sc->flags &= ~SC_FL_SHUTW_NOW;
+	sc->flags |= SC_FL_SHUTW;
 
 	sc->state = SC_ST_DIS;
 	if (sc->flags & SC_FL_ISBACK)
@@ -1199,7 +1198,7 @@
 		return 0;
 
 	/* maybe we were called immediately after an asynchronous shutr */
-	if (chn_prod(ic)->flags & SC_FL_SHUTR)
+	if (sc->flags & SC_FL_SHUTR)
 		return 1;
 
 	/* we must wait because the mux is not installed yet */
@@ -1330,7 +1329,7 @@
 	 */
 	while (sc_ep_test(sc, SE_FL_RCV_MORE) ||
 	       (!(conn->flags & CO_FL_HANDSHAKE) &&
-		(!sc_ep_test(sc, SE_FL_ERROR | SE_FL_EOS)) && !(chn_prod(ic)->flags & SC_FL_SHUTR))) {
+		(!sc_ep_test(sc, SE_FL_ERROR | SE_FL_EOS)) && !(sc->flags & SC_FL_SHUTR))) {
 		int cur_flags = flags;
 
 		/* Compute transient CO_RFL_* flags */
@@ -1494,7 +1493,7 @@
 	if (sc_ep_test(sc, SE_FL_ERROR))
 		ret = 1;
 	else if (!(sc->flags & (SC_FL_WONT_READ|SC_FL_NEED_BUFF|SC_FL_NEED_ROOM)) &&
-		 !(chn_prod(ic)->flags & SC_FL_SHUTR)) {
+		 !(sc->flags & SC_FL_SHUTR)) {
 		/* Subscribe to receive events if we're blocking on I/O */
 		conn->mux->subscribe(sc, SUB_RETRY_RECV, &sc->wait_event);
 		se_have_no_more_data(sc->sedesc);
@@ -1564,7 +1563,7 @@
 		return 0;
 
 	/* we might have been called just after an asynchronous shutw */
-	if (chn_cons(oc)->flags & SC_FL_SHUTW)
+	if (sc->flags & SC_FL_SHUTW)
 		return 1;
 
 	/* we must wait because the mux is not installed yet */
@@ -1609,10 +1608,10 @@
 		     ((oc->to_forward && oc->to_forward != CHN_INFINITE_FORWARD) ||
 		      (sc->flags & SC_FL_SND_EXP_MORE) ||
 		      (IS_HTX_STRM(s) &&
-		       (!(sco->flags & SC_FL_EOI) && !(chn_prod(oc)->flags & SC_FL_SHUTR) && htx_expect_more(htxbuf(&oc->buf)))))) ||
+		       (!(sco->flags & (SC_FL_EOI|SC_FL_SHUTR)) && htx_expect_more(htxbuf(&oc->buf)))))) ||
 		    ((oc->flags & CF_ISRESP) &&
 		     (oc->flags & CF_AUTO_CLOSE) &&
-		     (chn_cons(oc)->flags & SC_FL_SHUTW_NOW)))
+		     (sc->flags & SC_FL_SHUTW_NOW)))
 			send_flag |= CO_SFL_MSG_MORE;
 
 		if (oc->flags & CF_STREAMER)
@@ -1696,7 +1695,7 @@
 
 	oc->flags &= ~CF_WRITE_EVENT;
 
-	if (chn_cons(oc)->flags & SC_FL_SHUTW)
+	if (sc->flags & SC_FL_SHUTW)
 		return;
 
 	if (channel_is_empty(oc))
@@ -1774,7 +1773,7 @@
 	 *       wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take
 	 *       care of it.
 	 */
-	if (sc_ep_test(sc, SE_FL_EOS) && !(chn_prod(ic)->flags & SC_FL_SHUTR)) {
+	if (sc_ep_test(sc, SE_FL_EOS) && !(sc->flags & SC_FL_SHUTR)) {
 		/* we received a shutdown */
 		if (ic->flags & CF_AUTO_CLOSE)
 			channel_shutw_now(ic);
@@ -1853,7 +1852,7 @@
 	/* 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(sc, SE_FL_HAVE_NO_DATA) && (chn_prod(ic)->flags & SC_FL_SHUTR))
+	if (!sc_ep_test(sc, SE_FL_HAVE_NO_DATA) && (sc->flags & SC_FL_SHUTR))
 		sc_ep_set(sc, SE_FL_ERROR);
 
 	/* automatically mark the applet having data available if it reported
diff --git a/src/stick_table.c b/src/stick_table.c
index bb4dd5a..7ff4c47 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -5044,7 +5044,7 @@
 	 *     data though.
 	 */
 	/* FIXME: Don't watch the other side !*/
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW)) {
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW)) {
 		/* in case of abort, remove any refcount we might have set on an entry */
 		if (ctx->state == STATE_DUMP) {
 			stksess_kill_if_expired(ctx->t, ctx->entry, 1);
diff --git a/src/stream.c b/src/stream.c
index b53a603..803dbe8 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -3599,7 +3599,8 @@
 		goto done;
 	}
 
-	if (unlikely(chn_cons(sc_ic(sc))->flags & SC_FL_SHUTW)) {
+	/* FIXME: Don't watch the other side !*/
+	if (unlikely(sc_opposite(sc)->flags & SC_FL_SHUTW)) {
 		/* If we're forced to shut down, we might have to remove our
 		 * reference to the last stream being dumped.
 		 */