MEDIUM: stream-int: use si_rx_shut_blk() to indicate the SI is closed
Till now we were using si_done_put() upon shutr, but these flags could
be reset upon next activity. Now let's switch to SI_FL_RXBLK_SHUT which
doesn't go away. It's also set in stream_int_update() in case a shutr
condition is detected.
The now unused si_done_put() was removed.
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index c726f87..e7293d7 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -266,13 +266,6 @@
si->flags &= ~SI_FL_RX_WAIT_EP;
}
-/* Report that a stream interface won't put any more data into the input buffer */
-static inline void si_done_put(struct stream_interface *si)
-{
- si->flags &= ~SI_FL_RXBLK_ROOM;
- si->flags |= SI_FL_RX_WAIT_EP;
-}
-
/* The stream interface announces it is ready to try to deliver more data to the input buffer */
static inline void si_rx_endp_more(struct stream_interface *si)
{
@@ -301,6 +294,15 @@
si->flags |= SI_FL_RXBLK_BUFF;
}
+/* The stream interface announces it will never put new data into the input
+ * buffer and that it's not waiting for its endpoint to deliver anything else.
+ * This function obviously doesn't have a _rdy equivalent.
+ */
+static inline void si_rx_shut_blk(struct stream_interface *si)
+{
+ si->flags |= SI_FL_RXBLK_SHUT;
+}
+
/* Returns non-zero if the stream interface's Rx path is blocked */
static inline int si_tx_blocked(const struct stream_interface *si)
{
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 4e63ed2..df2adb3 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -157,12 +157,12 @@
{
struct channel *ic = si_ic(si);
+ si_rx_shut_blk(si);
ic->flags &= ~CF_SHUTR_NOW;
if (ic->flags & CF_SHUTR)
return;
ic->flags |= CF_SHUTR;
ic->rex = TICK_ETERNITY;
- si_done_put(si);
if (si->state != SI_ST_EST && si->state != SI_ST_CON)
return;
@@ -225,8 +225,8 @@
/* Note that none of these states may happen with applets */
si->state = SI_ST_DIS;
default:
- si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER);
- si->flags |= SI_FL_RX_WAIT_EP;
+ si->flags &= ~SI_FL_NOLINGER;
+ si_rx_shut_blk(si);
ic->flags &= ~CF_SHUTR_NOW;
ic->flags |= CF_SHUTR;
ic->rex = TICK_ETERNITY;
@@ -767,6 +767,8 @@
ic->rex = tick_add_ifset(now_ms, ic->rto);
}
}
+ else
+ si_rx_shut_blk(si);
if (!(oc->flags & CF_SHUTW)) {
/* Write not closed, update FD status and timeout for writes */
@@ -886,12 +888,12 @@
struct conn_stream *cs = __objt_cs(si->end);
struct channel *ic = si_ic(si);
+ si_rx_shut_blk(si);
ic->flags &= ~CF_SHUTR_NOW;
if (ic->flags & CF_SHUTR)
return;
ic->flags |= CF_SHUTR;
ic->rex = TICK_ETERNITY;
- si_done_put(si);
if (si->state != SI_ST_EST && si->state != SI_ST_CON)
return;
@@ -984,8 +986,8 @@
si->state = SI_ST_DIS;
/* fall through */
default:
- si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER);
- si->flags |= SI_FL_RX_WAIT_EP;
+ si->flags &= ~SI_FL_NOLINGER;
+ si_rx_shut_blk(si);
ic->flags &= ~CF_SHUTR_NOW;
ic->flags |= CF_SHUTR;
ic->rex = TICK_ETERNITY;
@@ -1369,12 +1371,12 @@
struct channel *ic = si_ic(si);
struct channel *oc = si_oc(si);
+ si_rx_shut_blk(si);
ic->flags &= ~CF_SHUTR_NOW;
if (ic->flags & CF_SHUTR)
return;
ic->flags |= CF_SHUTR;
ic->rex = TICK_ETERNITY;
- si_done_put(si);
if (si->state != SI_ST_EST && si->state != SI_ST_CON)
return;
@@ -1454,12 +1456,12 @@
{
struct channel *ic = si_ic(si);
+ si_rx_shut_blk(si);
ic->flags &= ~CF_SHUTR_NOW;
if (ic->flags & CF_SHUTR)
return;
ic->flags |= CF_SHUTR;
ic->rex = TICK_ETERNITY;
- si_done_put(si);
/* Note: on shutr, we don't call the applet */
@@ -1525,8 +1527,8 @@
si_applet_release(si);
si->state = SI_ST_DIS;
default:
- si->flags &= ~(SI_FL_RXBLK_ROOM | SI_FL_NOLINGER);
- si->flags |= SI_FL_RX_WAIT_EP;
+ si->flags &= ~SI_FL_NOLINGER;
+ si_rx_shut_blk(si);
ic->flags &= ~CF_SHUTR_NOW;
ic->flags |= CF_SHUTR;
ic->rex = TICK_ETERNITY;