MEDIUM: connection: start to introduce a mux layer between xprt and data
For HTTP/2 and QUIC, we'll need to deal with multiplexed streams inside
a connection. After quite a long brainstorming, it appears that the
connection interface to the existing streams is appropriate just like
the connection interface to the lower layers. In fact we need to have
the mux layer in the middle of the connection, between the transport
and the data layer.
A mux can exist on two directions/sides. On the inbound direction, it
instanciates new streams from incoming connections, while on the outbound
direction it muxes streams into outgoing connections. The difference is
visible on the mux->init() call : in one case, an upper context is already
known (outgoing connection), and in the other case, the upper context is
not yet known (incoming connection) and will have to be allocated by the
mux. The session doesn't have to create the new streams anymore, as this
is performed by the mux itself.
This patch introduces this and creates a pass-through mux called
"mux_pt" which is used for all new connections and which only
calls the data layer's recv,send,wake() calls. One incoming stream
is immediately created when init() is called on the inbound direction.
There should not be any visible impact.
Note that the connection's mux is purposely not set until the session
is completed so that we don't accidently run with the wrong mux. This
must not cause any issue as the xprt_done_cb function is always called
prior to using mux's recv/send functions.
diff --git a/src/connection.c b/src/connection.c
index d235ec5..129c741 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -105,7 +105,7 @@
* both of which will be detected below.
*/
flags = 0;
- conn->data->send(conn);
+ conn->mux->send(conn);
}
/* The data transfer starts here and stops on error and handshakes. Note
@@ -119,7 +119,7 @@
* both of which will be detected below.
*/
flags = 0;
- conn->data->recv(conn);
+ conn->mux->recv(conn);
}
/* It may happen during the data phase that a handshake is
@@ -169,7 +169,7 @@
if ((((conn->flags ^ flags) & CO_FL_NOTIFY_DATA) ||
((flags & (CO_FL_CONNECTED|CO_FL_HANDSHAKE)) != CO_FL_CONNECTED &&
(conn->flags & (CO_FL_CONNECTED|CO_FL_HANDSHAKE)) == CO_FL_CONNECTED)) &&
- conn->data->wake(conn) < 0)
+ conn->mux->wake(conn) < 0)
return;
/* remove the events before leaving */