]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: conn-stream: Add flags to set the type of the endpoint
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 18 Jan 2022 09:43:02 +0000 (10:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 13 Apr 2022 13:10:13 +0000 (15:10 +0200)
This patch is mandatory to invert the endpoint and the context in the
conn-stream. There is no common type (at least for now) for the entity
representing a mux (h1s, h2s...), thus we must set its type when the
endpoint is attached to a conn-stream. There is 2 types for the conn-stream
endpoints: the mux (CS_FL_ENDP_MUX) and the applet (CS_FL_ENDP_APP).

dev/flags/flags.c
include/haproxy/conn_stream-t.h
include/haproxy/conn_stream.h
src/conn_stream.c

index 126e9a022039e5b33c1975a96493fb39370592ed..48d9a86861f80f21af71eabc06404a18636bf675 100644 (file)
@@ -184,6 +184,8 @@ void show_cs_flags(unsigned int f)
                printf("0\n");
                return;
        }
+       SHOW_FLAG(f, CS_FL_ENDP_APP);
+       SHOW_FLAG(f, CS_FL_ENDP_MUX);
        SHOW_FLAG(f, CS_FL_WEBSOCKET);
        SHOW_FLAG(f, CS_FL_NOT_FIRST);
        SHOW_FLAG(f, CS_FL_KILL_CONN);
index 580d104bbbc2e3b56130ff62a2ea37f6a0249452..eee431890a0342b1300717df7a0565623a125e36 100644 (file)
@@ -57,6 +57,9 @@ enum {
 
        /* flags set by the mux relayed to the stream */
        CS_FL_WEBSOCKET     = 0x00200000,  /* websocket stream */
+
+       CS_FL_ENDP_MUX      = 0x00400000,  /* Endpoint is a mux */
+       CS_FL_ENDP_APP      = 0x00800000,  /* Endpoint is an applet */
 };
 
 /* cs_shutr() modes */
index e69f9c1701dceab974626d71948c0b9506c9d3b2..6304c1bf049c804a2d3ea144537e69cdaaffe630 100644 (file)
@@ -65,7 +65,7 @@ static inline struct connection *__cs_conn(const struct conn_stream *cs)
 }
 static inline struct connection *cs_conn(const struct conn_stream *cs)
 {
-       if (obj_type(cs->end) == OBJ_TYPE_CONN)
+       if (cs->flags & CS_FL_ENDP_MUX)
                return __cs_conn(cs);
        return NULL;
 }
@@ -90,7 +90,7 @@ static inline struct appctx *__cs_appctx(const struct conn_stream *cs)
 }
 static inline struct appctx *cs_appctx(const struct conn_stream *cs)
 {
-       if (obj_type(cs->end) == OBJ_TYPE_APPCTX)
+       if (cs->flags & CS_FL_ENDP_APP)
                return __cs_appctx(cs);
        return NULL;
 }
index 86db303612a217c6b5fff803cca979155f465aa5..d2fd7290870d65fba38847dc6677c80428ec9855 100644 (file)
@@ -60,6 +60,7 @@ void cs_attach_endp(struct conn_stream *cs, enum obj_type *endp, void *ctx)
                }
                else if (cs_check(cs))
                        cs->data_cb = &check_conn_cb;
+               cs->flags |= CS_FL_ENDP_MUX;
        }
        else if ((appctx = objt_appctx(endp)) != NULL) {
                appctx->owner = cs;
@@ -67,6 +68,7 @@ void cs_attach_endp(struct conn_stream *cs, enum obj_type *endp, void *ctx)
                        cs->si->ops = &si_applet_ops;
                        cs->data_cb = NULL;
                }
+               cs->flags |= CS_FL_ENDP_APP;
        }
 }