From 24d15b18919085927816e55fac4809038cda0f12 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 16 May 2022 17:17:16 +0200 Subject: [PATCH] CLEANUP: conn_stream: rename the cs_endpoint's context to "conn" This one is exclusively used by the connection, regardless its generic name "ctx" is rather confusing. Let's make it a struct connection* and call it "conn". This way there's no doubt about what it is and there's no way it will be used by accident by being taken for something else. --- include/haproxy/conn_stream-t.h | 4 ++-- include/haproxy/conn_stream.h | 8 +------- include/haproxy/mux_quic.h | 2 +- src/conn_stream.c | 6 +++--- src/mux_h1.c | 2 +- src/mux_h2.c | 2 +- src/mux_pt.c | 4 ++-- 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/include/haproxy/conn_stream-t.h b/include/haproxy/conn_stream-t.h index 6701107e4..b56e1bd03 100644 --- a/include/haproxy/conn_stream-t.h +++ b/include/haproxy/conn_stream-t.h @@ -157,13 +157,13 @@ struct data_cb { * new cs-endpoint (for instance on connection retries). * * is the mux or the appctx - * is the context set and used by + * is the connection for connection-based streams * is the conn_stream we're attached to, or NULL * CS_EP_* */ struct cs_endpoint { void *target; - void *ctx; + struct connection *conn; struct conn_stream *cs; unsigned int flags; }; diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h index cfc8a4925..162975482 100644 --- a/include/haproxy/conn_stream.h +++ b/include/haproxy/conn_stream.h @@ -56,19 +56,13 @@ static inline void *__cs_endp_target(const struct conn_stream *cs) return cs->endp->target; } -/* Returns the endpoint context without any control */ -static inline void *__cs_endp_ctx(const struct conn_stream *cs) -{ - return cs->endp->ctx; -} - /* Returns the connection from a cs if the endpoint is a mux stream. Otherwise * NULL is returned. __cs_conn() returns the connection without any control * while cs_conn() check the endpoint type. */ static inline struct connection *__cs_conn(const struct conn_stream *cs) { - return __cs_endp_ctx(cs); + return cs->endp->conn; } static inline struct connection *cs_conn(const struct conn_stream *cs) { diff --git a/include/haproxy/mux_quic.h b/include/haproxy/mux_quic.h index 1d71abde8..b3284b174 100644 --- a/include/haproxy/mux_quic.h +++ b/include/haproxy/mux_quic.h @@ -101,7 +101,7 @@ static inline struct conn_stream *qc_attach_cs(struct qcs *qcs, struct buffer *b return NULL; qcs->endp->target = qcs; - qcs->endp->ctx = qcc->conn; + qcs->endp->conn = qcc->conn; qcs->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN|CS_EP_NOT_FIRST); /* TODO duplicated from mux_h2 */ diff --git a/src/conn_stream.c b/src/conn_stream.c index 772feb9bc..9147edac9 100644 --- a/src/conn_stream.c +++ b/src/conn_stream.c @@ -85,7 +85,7 @@ struct data_cb cs_data_applet_cb = { void cs_endpoint_init(struct cs_endpoint *endp) { endp->target = NULL; - endp->ctx = NULL; + endp->conn = NULL; endp->cs = NULL; endp->flags = CS_EP_NONE; } @@ -248,7 +248,7 @@ int cs_attach_mux(struct conn_stream *cs, void *target, void *ctx) struct connection *conn = ctx; cs->endp->target = target; - cs->endp->ctx = ctx; + cs->endp->conn = ctx; cs->endp->flags |= CS_EP_T_MUX; cs->endp->flags &= ~CS_EP_DETACHED; if (!conn->ctx) @@ -381,7 +381,7 @@ static void cs_detach_endp(struct conn_stream **csp) if (cs->endp) { /* the cs is the only one one the endpoint */ cs->endp->target = NULL; - cs->endp->ctx = NULL; + cs->endp->conn = NULL; cs->endp->flags &= CS_EP_APP_MASK; cs->endp->flags |= CS_EP_DETACHED; } diff --git a/src/mux_h1.c b/src/mux_h1.c index c5f0b0320..14e399fe1 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -822,7 +822,7 @@ static struct h1s *h1c_frt_stream_new(struct h1c *h1c, struct conn_stream *cs, s if (!h1s->endp) goto fail; h1s->endp->target = h1s; - h1s->endp->ctx = h1c->conn; + h1s->endp->conn = h1c->conn; h1s->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN); } diff --git a/src/mux_h2.c b/src/mux_h2.c index 9ed272768..cd57d98f6 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1613,7 +1613,7 @@ static struct h2s *h2c_frt_stream_new(struct h2c *h2c, int id, struct buffer *in if (!h2s->endp) goto out_close; h2s->endp->target = h2s; - h2s->endp->ctx = h2c->conn; + h2s->endp->conn = h2c->conn; h2s->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN|CS_EP_NOT_FIRST); /* FIXME wrong analogy between ext-connect and websocket, this need to diff --git a/src/mux_pt.c b/src/mux_pt.c index 821f558ba..338e4fe34 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -299,7 +299,7 @@ static int mux_pt_init(struct connection *conn, struct proxy *prx, struct sessio goto fail_free_ctx; } ctx->endp->target = ctx; - ctx->endp->ctx = conn; + ctx->endp->conn = conn; ctx->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN); cs = cs_new_from_endp(ctx->endp, sess, input); @@ -419,7 +419,7 @@ static void mux_pt_destroy_meth(void *ctx) */ static void mux_pt_detach(struct cs_endpoint *endp) { - struct connection *conn = endp->ctx; + struct connection *conn = endp->conn; struct mux_pt_ctx *ctx; TRACE_ENTER(PT_EV_STRM_END, conn, endp->cs);