MEDIUM: conn-stream: Add an endpoint structure in the conn-stream
Group the endpoint target of a conn-stream, its context and the associated
flags in a dedicated structure in the conn-stream. It is not inlined in the
conn-stream structure. There is a dedicated pool.
For now, there is no complexity. It is just an indirection to get the
endpoint or its context. But the purpose of this structure is to be able to
share a refcounted context between the mux and the conn-stream. This way, it
will be possible to preserve it when the mux is detached from the
conn-stream.
diff --git a/src/mux_h2.c b/src/mux_h2.c
index d06b093..7e7bc66 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -4349,14 +4349,12 @@
*/
static void h2_detach(struct conn_stream *cs)
{
- struct h2s *h2s = cs->end;
+ struct h2s *h2s = __cs_mux(cs);
struct h2c *h2c;
struct session *sess;
TRACE_ENTER(H2_EV_STRM_END, h2s ? h2s->h2c->conn : NULL, h2s);
- cs->end = NULL;
- cs->ctx = NULL;
if (!h2s) {
TRACE_LEAVE(H2_EV_STRM_END);
return;
@@ -4670,7 +4668,7 @@
/* shutr() called by the conn_stream (mux_ops.shutr) */
static void h2_shutr(struct conn_stream *cs, enum cs_shr_mode mode)
{
- struct h2s *h2s = cs->end;
+ struct h2s *h2s = __cs_mux(cs);
TRACE_ENTER(H2_EV_STRM_SHUT, h2s->h2c->conn, h2s);
if (cs->flags & CS_FL_KILL_CONN)
@@ -4685,7 +4683,7 @@
/* shutw() called by the conn_stream (mux_ops.shutw) */
static void h2_shutw(struct conn_stream *cs, enum cs_shw_mode mode)
{
- struct h2s *h2s = cs->end;
+ struct h2s *h2s = __cs_mux(cs);
TRACE_ENTER(H2_EV_STRM_SHUT, h2s->h2c->conn, h2s);
if (cs->flags & CS_FL_KILL_CONN)
@@ -6362,7 +6360,7 @@
*/
static int h2_subscribe(struct conn_stream *cs, int event_type, struct wait_event *es)
{
- struct h2s *h2s = cs->end;
+ struct h2s *h2s = __cs_mux(cs);
struct h2c *h2c = h2s->h2c;
TRACE_ENTER(H2_EV_STRM_SEND|H2_EV_STRM_RECV, h2c->conn, h2s);
@@ -6396,7 +6394,7 @@
*/
static int h2_unsubscribe(struct conn_stream *cs, int event_type, struct wait_event *es)
{
- struct h2s *h2s = cs->end;
+ struct h2s *h2s = __cs_mux(cs);
TRACE_ENTER(H2_EV_STRM_SEND|H2_EV_STRM_RECV, h2s->h2c->conn, h2s);
@@ -6436,7 +6434,7 @@
*/
static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
{
- struct h2s *h2s = cs->end;
+ struct h2s *h2s = __cs_mux(cs);
struct h2c *h2c = h2s->h2c;
struct htx *h2s_htx = NULL;
struct htx *buf_htx = NULL;
@@ -6519,7 +6517,7 @@
*/
static size_t h2_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
{
- struct h2s *h2s = cs->end;
+ struct h2s *h2s = __cs_mux(cs);
size_t total = 0;
size_t ret;
struct htx *htx;