MEDIUM: stream-int: introduce a new state SI_ST_RDY
The main reason for all the trouble we're facing with stream interface
error or timeout reports during the connection phase is that we currently
can't make the difference between a connection attempt and a validated
connection attempt. It is problematic because we tend to switch early
to SI_ST_EST but can't always do what we want in this state since it's
supposed to be set when we don't need to visit sess_establish() again.
This patch introduces a new state betwen SI_ST_CON and SI_ST_EST, which
is SI_ST_RDY. It indicates that we've verified that the connection is
ready. It's a transient state, like SI_ST_DIS, that cannot persist when
leaving process_stream(). For now it is not set, only verified in various
tests where SI_ST_CON was used or SI_ST_EST depending on the cases.
The stream-int state diagram was minimally updated to reflect the new
state, though it is largely obsolete and would need to be seriously
updated.
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 59b5c15..17a0c74 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -448,13 +448,13 @@
*/
static inline void si_chk_rcv(struct stream_interface *si)
{
- if (si->flags & SI_FL_RXBLK_CONN && si_state_in(si_opposite(si)->state, SI_SB_EST|SI_SB_DIS|SI_SB_CLO))
+ if (si->flags & SI_FL_RXBLK_CONN && si_state_in(si_opposite(si)->state, SI_SB_RDY|SI_SB_EST|SI_SB_DIS|SI_SB_CLO))
si_rx_conn_rdy(si);
if (si_rx_blocked(si) || !si_rx_endp_ready(si))
return;
- if (!si_state_in(si->state, SI_SB_EST))
+ if (!si_state_in(si->state, SI_SB_RDY|SI_SB_EST))
return;
si->flags |= SI_FL_RX_WAIT_EP;
@@ -472,7 +472,7 @@
{
struct conn_stream *cs;
- if (!si_state_in(si->state, SI_SB_EST))
+ if (!si_state_in(si->state, SI_SB_RDY|SI_SB_EST))
return 0;
cs = objt_cs(si->end);
@@ -552,6 +552,7 @@
case SI_ST_ASS: return "ASS";
case SI_ST_CON: return "CON";
case SI_ST_CER: return "CER";
+ case SI_ST_RDY: return "RDY";
case SI_ST_EST: return "EST";
case SI_ST_DIS: return "DIS";
case SI_ST_CLO: return "CLO";
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index 86df1d2..e45eb6f 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -38,6 +38,7 @@
SI_ST_ASS, /* server just assigned to this interface */
SI_ST_CON, /* initiated connection request (resource exists) */
SI_ST_CER, /* [transient] previous connection attempt failed (resource released) */
+ SI_ST_RDY, /* [transient] ready proven after I/O success during SI_ST_CON */
SI_ST_EST, /* connection established (resource exists) */
SI_ST_DIS, /* [transient] disconnected from other side, but cleanup not done yet */
SI_ST_CLO, /* stream intf closed, might not existing anymore. Buffers shut. */
@@ -53,10 +54,11 @@
SI_SB_ASS = 1U << SI_ST_ASS,
SI_SB_CON = 1U << SI_ST_CON,
SI_SB_CER = 1U << SI_ST_CER,
+ SI_SB_RDY = 1U << SI_ST_RDY,
SI_SB_EST = 1U << SI_ST_EST,
SI_SB_DIS = 1U << SI_ST_DIS,
SI_SB_CLO = 1U << SI_ST_CLO,
- SI_SB_ALL = SI_SB_INI|SI_SB_REQ|SI_SB_QUE|SI_SB_TAR|SI_SB_ASS|SI_SB_CON|SI_SB_CER|SI_SB_EST|SI_SB_DIS|SI_SB_CLO,
+ SI_SB_ALL = SI_SB_INI|SI_SB_REQ|SI_SB_QUE|SI_SB_TAR|SI_SB_ASS|SI_SB_CON|SI_SB_CER|SI_SB_RDY|SI_SB_EST|SI_SB_DIS|SI_SB_CLO,
};
/* error types reported on the streams interface for more accurate reporting */