]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: conn_stream: rename the conn_stream's endp to sedesc
authorWilly Tarreau <w@1wt.eu>
Tue, 17 May 2022 16:20:02 +0000 (18:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 May 2022 17:33:34 +0000 (19:33 +0200)
Just like for the appctx, this is a pointer to a stream endpoint descriptor,
so let's make this explicit and not confuse it with the full endpoint. There
are very few changes thanks to the preliminary refactoring of the flags
manipulation.

include/haproxy/conn_stream-t.h
include/haproxy/conn_stream.h
src/backend.c
src/cli.c
src/conn_stream.c
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/mux_pt.c
src/stream.c

index 3e072aed3c8e79727de1b8d33b933800fd71ec04..c60303d1cbd8a132f01e201741292cd0c2b175fc 100644 (file)
@@ -192,7 +192,7 @@ struct conn_stream {
        unsigned int flags;                  /* CS_FL_* */
        unsigned int hcto;                   /* half-closed timeout (0 = unset) */
        struct wait_event wait_event;        /* We're in a wait list */
-       struct sedesc *endp;                 /* points to the end point (MUX stream or appctx) */
+       struct sedesc *sedesc;               /* points to the stream endpoint descriptor */
        enum obj_type *app;                  /* points to the applicative point (stream or check) */
        const struct data_cb *data_cb;       /* data layer callbacks. Must be set before xprt->init() */
        struct cs_app_ops *ops;              /* general operations used at the app layer */
index 8db8f68ac2628c97f63fac79009c2e57101ea5bd..dae46ddc9cfeeb481ef3f27a2570a96ca162df28 100644 (file)
@@ -95,39 +95,39 @@ static forceinline uint se_fl_get(const struct sedesc *se)
 /* stream connector version */
 static forceinline void sc_ep_zero(struct conn_stream *sc)
 {
-       se_fl_zero(sc->endp);
+       se_fl_zero(sc->sedesc);
 }
 
 static forceinline void sc_ep_setall(struct conn_stream *sc, uint all)
 {
-       se_fl_setall(sc->endp, all);
+       se_fl_setall(sc->sedesc, all);
 }
 
 static forceinline void sc_ep_set(struct conn_stream *sc, uint on)
 {
-       se_fl_set(sc->endp, on);
+       se_fl_set(sc->sedesc, on);
 }
 
 static forceinline void sc_ep_clr(struct conn_stream *sc, uint off)
 {
-       se_fl_clr(sc->endp, off);
+       se_fl_clr(sc->sedesc, off);
 }
 
 static forceinline uint sc_ep_test(const struct conn_stream *sc, uint test)
 {
-       return se_fl_test(sc->endp, test);
+       return se_fl_test(sc->sedesc, test);
 }
 
 static forceinline uint sc_ep_get(const struct conn_stream *sc)
 {
-       return se_fl_get(sc->endp);
+       return se_fl_get(sc->sedesc);
 }
 
 
 /* Returns the endpoint target without any control */
 static inline void *__cs_endp_target(const struct conn_stream *cs)
 {
-       return cs->endp->se;
+       return cs->sedesc->se;
 }
 
 /* Returns the connection from a cs if the endpoint is a mux stream. Otherwise
@@ -136,7 +136,7 @@ static inline void *__cs_endp_target(const struct conn_stream *cs)
  */
 static inline struct connection *__cs_conn(const struct conn_stream *cs)
 {
-       return cs->endp->conn;
+       return cs->sedesc->conn;
 }
 static inline struct connection *cs_conn(const struct conn_stream *cs)
 {
index eb4ad7d2c87daeb69b6a3d12fe686da0466a648f..55773acd6bad0ed533f00cc1412ee9965ccfd538 100644 (file)
@@ -1574,7 +1574,7 @@ static int connect_server(struct stream *s)
                        }
 
                        if (avail >= 1) {
-                               if (srv_conn->mux->attach(srv_conn, s->csb->endp, s->sess) == -1) {
+                               if (srv_conn->mux->attach(srv_conn, s->csb->sedesc, s->sess) == -1) {
                                        srv_conn = NULL;
                                        if (cs_reset_endp(s->csb) < 0)
                                                return SF_ERR_INTERNAL;
index 9d17df97a9b6b52ee7a1372865e92b85dd35cf16..fe2958351d53b8f1dc0b8a31f5691c031be6ba8e 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2782,7 +2782,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
                                        s->srv_error(s, s->csb);
                                return 1;
                        }
-                       se_fl_clr(s->csb->endp, ~SE_FL_DETACHED);
+                       se_fl_clr(s->csb->sedesc, ~SE_FL_DETACHED);
                }
 
                sockaddr_free(&s->csb->dst);
index da81d27a9ee83cc418f4d3759b0c06f88af302e6..e84021f7096d5f92069de8f1a8300ca3d31a3bb6 100644 (file)
@@ -142,7 +142,7 @@ static struct conn_stream *cs_new(struct sedesc *sedesc)
                if (unlikely(!sedesc))
                        goto alloc_error;
        }
-       cs->endp = sedesc;
+       cs->sedesc = sedesc;
        sedesc->cs = cs;
 
        return cs;
@@ -215,9 +215,9 @@ void cs_free(struct conn_stream *cs)
 {
        sockaddr_free(&cs->src);
        sockaddr_free(&cs->dst);
-       if (cs->endp) {
+       if (cs->sedesc) {
                BUG_ON(!sc_ep_test(cs, SE_FL_DETACHED));
-               sedesc_free(cs->endp);
+               sedesc_free(cs->sedesc);
        }
        if (cs->wait_event.tasklet)
                tasklet_free(cs->wait_event.tasklet);
@@ -232,7 +232,7 @@ static void cs_free_cond(struct conn_stream **csp)
 {
        struct conn_stream *cs = *csp;
 
-       if (!cs->app && (!cs->endp || sc_ep_test(cs, SE_FL_DETACHED))) {
+       if (!cs->app && (!cs->sedesc || sc_ep_test(cs, SE_FL_DETACHED))) {
                cs_free(cs);
                *csp = NULL;
        }
@@ -246,11 +246,12 @@ static void cs_free_cond(struct conn_stream **csp)
 int cs_attach_mux(struct conn_stream *cs, void *endp, void *ctx)
 {
        struct connection *conn = ctx;
+       struct sedesc *sedesc = cs->sedesc;
 
-       cs->endp->se     = endp;
-       cs->endp->conn   = ctx;
-       sc_ep_set(cs, SE_FL_T_MUX);
-       sc_ep_clr(cs, SE_FL_DETACHED);
+       sedesc->se = endp;
+       sedesc->conn = ctx;
+       se_fl_set(sedesc, SE_FL_T_MUX);
+       se_fl_clr(sedesc, SE_FL_DETACHED);
        if (!conn->ctx)
                conn->ctx = cs;
        if (cs_strm(cs)) {
@@ -288,7 +289,7 @@ int cs_attach_mux(struct conn_stream *cs, void *endp, void *ctx)
  */
 static void cs_attach_applet(struct conn_stream *cs, void *endp)
 {
-       cs->endp->se = endp;
+       cs->sedesc->se = endp;
        sc_ep_set(cs, SE_FL_T_APPLET);
        sc_ep_clr(cs, SE_FL_DETACHED);
        if (cs_strm(cs)) {
@@ -342,20 +343,20 @@ static void cs_detach_endp(struct conn_stream **csp)
        if (!cs)
                return;
 
-       if (!cs->endp)
+       if (!cs->sedesc)
                goto reset_cs;
 
        if (sc_ep_test(cs, SE_FL_T_MUX)) {
                struct connection *conn = __cs_conn(cs);
-               struct sedesc *endp = cs->endp;
+               struct sedesc *sedesc = cs->sedesc;
 
                if (conn->mux) {
                        if (cs->wait_event.events != 0)
                                conn->mux->unsubscribe(cs, cs->wait_event.events, &cs->wait_event);
-                       se_fl_set(endp, SE_FL_ORPHAN);
-                       endp->cs = NULL;
-                       cs->endp = NULL;
-                       conn->mux->detach(endp);
+                       se_fl_set(sedesc, SE_FL_ORPHAN);
+                       sedesc->cs = NULL;
+                       cs->sedesc = NULL;
+                       conn->mux->detach(sedesc);
                }
                else {
                        /* It's too early to have a mux, let's just destroy
@@ -372,16 +373,16 @@ static void cs_detach_endp(struct conn_stream **csp)
                struct appctx *appctx = __cs_appctx(cs);
 
                sc_ep_set(cs, SE_FL_ORPHAN);
-               cs->endp->cs = NULL;
-               cs->endp = NULL;
+               cs->sedesc->cs = NULL;
+               cs->sedesc = NULL;
                appctx_shut(appctx);
                appctx_free(appctx);
        }
 
-       if (cs->endp) {
+       if (cs->sedesc) {
                /* the cs is the only one one the endpoint */
-               cs->endp->se     = NULL;
-               cs->endp->conn   = NULL;
+               cs->sedesc->se     = NULL;
+               cs->sedesc->conn   = NULL;
                sc_ep_clr(cs, ~SE_FL_APP_MASK);
                sc_ep_set(cs, SE_FL_DETACHED);
        }
@@ -464,9 +465,9 @@ int cs_reset_endp(struct conn_stream *cs)
 
        /* The app is still attached, the cs will not be released */
        cs_detach_endp(&cs);
-       BUG_ON(cs->endp);
-       cs->endp = new_endp;
-       cs->endp->cs = cs;
+       BUG_ON(cs->sedesc);
+       cs->sedesc = new_endp;
+       cs->sedesc->cs = cs;
        sc_ep_set(cs, SE_FL_DETACHED);
        return 0;
 }
@@ -484,7 +485,7 @@ struct appctx *cs_applet_create(struct conn_stream *cs, struct applet *app)
 
        DPRINTF(stderr, "registering handler %p for cs %p (was %p)\n", app, cs, cs_strm_task(cs));
 
-       appctx = appctx_new_here(app, cs->endp);
+       appctx = appctx_new_here(app, cs->sedesc);
        if (!appctx)
                return NULL;
        cs_attach_applet(cs, appctx);
index 62d4a615d1cd63741d5c3128c9a4701ea410fa25..ffaa81b538545805d65f1b2364fc86f1ac3432cc 100644 (file)
@@ -1131,7 +1131,7 @@ static struct fcgi_strm *fcgi_conn_stream_new(struct fcgi_conn *fconn, struct co
        }
        if (cs_attach_mux(cs, fstrm, fconn->conn) < 0)
                goto out;
-       fstrm->endp = cs->endp;
+       fstrm->endp = cs->sedesc;
        fstrm->sess = sess;
        fconn->nb_cs++;
 
index f4a62e39b439024196d5d34e75136594d930da8f..b00e63c14bc63daf39de44552bd51cb7b8b3fcb9 100644 (file)
@@ -815,7 +815,7 @@ static struct h1s *h1c_frt_stream_new(struct h1c *h1c, struct conn_stream *cs, s
        if (cs) {
                if (cs_attach_mux(cs, h1s, h1c->conn) < 0)
                        goto fail;
-               h1s->endp = cs->endp;
+               h1s->endp = cs->sedesc;
        }
        else {
                h1s->endp = sedesc_new();
@@ -856,7 +856,7 @@ static struct h1s *h1c_bck_stream_new(struct h1c *h1c, struct conn_stream *cs, s
                goto fail;
 
        h1s->flags |= H1S_F_RX_BLK;
-       h1s->endp = cs->endp;
+       h1s->endp = cs->sedesc;
        h1s->sess = sess;
 
        h1c->flags = (h1c->flags & ~H1C_F_ST_EMBRYONIC) | H1C_F_ST_ATTACHED | H1C_F_ST_READY;
index 1b4c16f79f76797e8817fe011d131995f076f213..4f83cabca4a4ca10f76e4e82b37a652148f0c443 100644 (file)
@@ -1693,7 +1693,7 @@ static struct h2s *h2c_bck_stream_new(struct h2c *h2c, struct conn_stream *cs, s
                h2s = NULL;
                goto out;
        }
-       h2s->endp = cs->endp;
+       h2s->endp = cs->sedesc;
        h2s->sess = sess;
        h2c->nb_cs++;
 
index 42dadf9077ff011af54559cdcdfdfa7b23b9d36a..54ccca7907c4a8a5da335f2883f1cbe35f818ed5 100644 (file)
@@ -312,7 +312,7 @@ static int mux_pt_init(struct connection *conn, struct proxy *prx, struct sessio
        else {
                if (cs_attach_mux(cs, ctx, conn) < 0)
                        goto fail_free_ctx;
-               ctx->endp = cs->endp;
+               ctx->endp = cs->sedesc;
        }
        conn->ctx = ctx;
        se_fl_set(ctx->endp, SE_FL_RCV_MORE);
index 91ceeb4e4a1b74b9fa1da8885ca220501505b13a..7c348cdf0f5fa5b228cb09a670b079f38e14072b 100644 (file)
@@ -3308,7 +3308,7 @@ static int stats_dump_full_strm_to_buffer(struct conn_stream *cs, struct stream
                chunk_appendf(&trash, "  csf=%p flags=0x%08x state=%s endp=%s,%p,0x%08x sub=%d\n",
                              csf, csf->flags, cs_state_str(csf->state),
                              (sc_ep_test(csf, SE_FL_T_MUX) ? "CONN" : (sc_ep_test(csf, SE_FL_T_APPLET) ? "APPCTX" : "NONE")),
-                             csf->endp->se, sc_ep_get(csf), csf->wait_event.events);
+                             csf->sedesc->se, sc_ep_get(csf), csf->wait_event.events);
 
                if ((conn = cs_conn(csf)) != NULL) {
                        chunk_appendf(&trash,
@@ -3347,7 +3347,7 @@ static int stats_dump_full_strm_to_buffer(struct conn_stream *cs, struct stream
                chunk_appendf(&trash, "  csb=%p flags=0x%08x state=%s endp=%s,%p,0x%08x sub=%d\n",
                              csb, csb->flags, cs_state_str(csb->state),
                              (sc_ep_test(csb, SE_FL_T_MUX) ? "CONN" : (sc_ep_test(csb, SE_FL_T_APPLET) ? "APPCTX" : "NONE")),
-                             csb->endp->se, sc_ep_get(csb), csb->wait_event.events);
+                             csb->sedesc->se, sc_ep_get(csb), csb->wait_event.events);
 
                if ((conn = cs_conn(csb)) != NULL) {
                        chunk_appendf(&trash,