MAJOR: conn-stream: Invert conn-stream endpoint and its context
This change is only significant for the multiplexer part. For the applets,
the context and the endpoint are the same. Thus, there is no much change. For
the multiplexer part, the connection was used to set the conn-stream
endpoint and the mux's stream was the context. But it is a bit strange
because once a mux is installed, it takes over the connection. In a
wonderful world, the connection should be totally hidden behind the mux. The
stream-interface and, in a lesser extent, the stream, still access the
connection because that was inherited from the pre-multiplexer era.
Now, the conn-stream endpoint is the mux's stream (an opaque entity for the
conn-stream) and the connection is the context. Dedicated functions have
been added to attached an applet or a mux to a conn-stream.
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 29dee6f..4baaf43 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -724,7 +724,7 @@
TRACE_ERROR("CS allocation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1c->conn, h1s);
goto err;
}
- cs_attach_endp(cs, &h1c->conn->obj_type, h1s);
+ cs_attach_endp_mux(cs, h1s, h1c->conn);
h1s->cs = cs;
if (h1s->flags & H1S_F_NOT_FIRST)
@@ -848,10 +848,10 @@
if (!h1s)
goto fail;
+ cs_attach_endp_mux(cs, h1s, h1c->conn);
h1s->flags |= H1S_F_RX_BLK;
h1s->cs = cs;
h1s->sess = sess;
- cs->ctx = h1s;
h1c->flags = (h1c->flags & ~H1C_F_ST_EMBRYONIC) | H1C_F_ST_ATTACHED | H1C_F_ST_READY;
@@ -995,9 +995,8 @@
if (!h1c_frt_stream_new(h1c))
goto fail;
-
h1c->h1s->cs = cs;
- cs->ctx = h1c->h1s;
+ cs_attach_endp_mux(cs, h1c->h1s, conn);
/* Attach the CS but Not ready yet */
h1c->flags = (h1c->flags & ~H1C_F_ST_EMBRYONIC) | H1C_F_ST_ATTACHED;
@@ -3338,13 +3337,14 @@
*/
static void h1_detach(struct conn_stream *cs)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
struct h1c *h1c;
struct session *sess;
int is_not_first;
TRACE_ENTER(H1_EV_STRM_END, h1s ? h1s->h1c->conn : NULL, h1s);
+ cs->end = NULL;
cs->ctx = NULL;
if (!h1s) {
TRACE_LEAVE(H1_EV_STRM_END);
@@ -3447,7 +3447,7 @@
static void h1_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
struct h1c *h1c;
if (!h1s)
@@ -3490,7 +3490,7 @@
static void h1_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
struct h1c *h1c;
if (!h1s)
@@ -3550,7 +3550,7 @@
*/
static int h1_unsubscribe(struct conn_stream *cs, int event_type, struct wait_event *es)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
if (!h1s)
return 0;
@@ -3579,7 +3579,7 @@
*/
static int h1_subscribe(struct conn_stream *cs, int event_type, struct wait_event *es)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
struct h1c *h1c;
if (!h1s)
@@ -3627,7 +3627,7 @@
*/
static size_t h1_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
struct h1c *h1c = h1s->h1c;
struct h1m *h1m = (!(h1c->flags & H1C_F_IS_BACK) ? &h1s->req : &h1s->res);
size_t ret = 0;
@@ -3663,7 +3663,7 @@
/* Called from the upper layer, to send data */
static size_t h1_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
struct h1c *h1c;
size_t total = 0;
@@ -3728,7 +3728,7 @@
/* Send and get, using splicing */
static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int count)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
struct h1c *h1c = h1s->h1c;
struct h1m *h1m = (!(h1c->flags & H1C_F_IS_BACK) ? &h1s->req : &h1s->res);
int ret = 0;
@@ -3798,7 +3798,7 @@
static int h1_snd_pipe(struct conn_stream *cs, struct pipe *pipe)
{
- struct h1s *h1s = cs->ctx;
+ struct h1s *h1s = cs->end;
struct h1c *h1c = h1s->h1c;
struct h1m *h1m = (!(h1c->flags & H1C_F_IS_BACK) ? &h1s->res : &h1s->req);
int ret = 0;