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.
This commit is contained in:
Willy Tarreau 2022-05-16 17:17:16 +02:00
parent 5fec7a1f98
commit 24d15b1891
7 changed files with 11 additions and 17 deletions

View File

@ -157,13 +157,13 @@ struct data_cb {
* new cs-endpoint (for instance on connection retries).
*
* <target> is the mux or the appctx
* <ctx> is the context set and used by <target>
* <conn> is the connection for connection-based streams
* <cs> is the conn_stream we're attached to, or NULL
* <flags> CS_EP_*
*/
struct cs_endpoint {
void *target;
void *ctx;
struct connection *conn;
struct conn_stream *cs;
unsigned int flags;
};

View File

@ -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)
{

View File

@ -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 */

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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

View File

@ -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);