MEDIUM: conn-stream: Be able to pass endpoint to create a conn-stream
It is a transient commit to prepare next changes. It is possible to pass a
pre-allocated endpoint to create a new conn-stream. If it is NULL, a new
endpoint is created, otherwise the existing one is used. There no more
change at the conn-stream level.
In the applets, all conn-stream are created with no pre-allocated
endpoint. But for multiplexers, an endpoint is systematically created before
creating the conn-stream.
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 82196e9..98a837d 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -1590,6 +1590,7 @@
static struct h2s *h2c_frt_stream_new(struct h2c *h2c, int id, struct buffer *input, uint32_t flags)
{
struct session *sess = h2c->conn->owner;
+ struct cs_endpoint *endp;
struct conn_stream *cs;
struct h2s *h2s;
@@ -1602,19 +1603,26 @@
if (!h2s)
goto out;
- cs = cs_new();
- if (!cs)
+ endp = cs_endpoint_new();
+ if (!endp)
goto out_close;
- cs->endp->flags |= CS_EP_NOT_FIRST;
- cs_attach_endp_mux(cs, h2s, h2c->conn);
- h2s->cs = cs;
- h2c->nb_cs++;
-
+ endp->target = h2s;
+ endp->ctx = h2c->conn;
+ endp->flags |= CS_EP_NOT_FIRST;
/* FIXME wrong analogy between ext-connect and websocket, this need to
* be refine.
*/
if (flags & H2_SF_EXT_CONNECT_RCVD)
- cs->endp->flags |= CS_EP_WEBSOCKET;
+ endp->flags |= CS_EP_WEBSOCKET;
+
+ cs = cs_new(endp);
+ if (!cs) {
+ cs_endpoint_free(endp);
+ goto out_close;
+ }
+ cs_attach_endp_mux(cs, h2s, h2c->conn);
+ h2s->cs = cs;
+ h2c->nb_cs++;
/* The stream will record the request's accept date (which is either the
* end of the connection's or the date immediately after the previous