]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stconn: stream instantiation from proxy callback
authorFrederic Lecaille <flecaille@haproxy.com>
Wed, 11 Feb 2026 13:43:58 +0000 (14:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Feb 2026 13:46:49 +0000 (14:46 +0100)
Add a pointer to function to proxies as ->stream_new_from_sc proxy
struct member to instantiate stream from connection as this is done by
all the muxes when they call sc_new_from_endp(). The default value for
this pointer is obviously stream_new() which is exported by this patch.

include/haproxy/proxy-t.h
include/haproxy/stream.h
src/proxy.c
src/stconn.c
src/stream.c

index 5f58bdb4c5b388902668defd57ea9488ee4ad2ff..21c9aae4f47366bfc0463e72aedb5fcad647aed9 100644 (file)
@@ -413,6 +413,7 @@ struct proxy {
        int redispatch_after;                   /* number of retries before redispatch */
        unsigned down_time;                     /* total time the proxy was down */
        int (*accept)(struct stream *s);       /* application layer's accept() */
+       void *(*stream_new_from_sc)(struct session *sess, struct stconn *sc, struct buffer *in); /* stream instantiation callback for mux stream connector */
        struct conn_src conn_src;               /* connection source settings */
        enum obj_type *default_target;          /* default target to use for accepted streams or NULL */
        struct proxy *next;
index 78d828fb230871845eb6e0e0510a7e8a75c7f460..46464f8601147db9bef406b7dcbb0f22e36643e7 100644 (file)
@@ -59,7 +59,7 @@ extern struct pool_head *pool_head_uniqueid;
 
 extern struct data_cb sess_conn_cb;
 
-struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer *input);
+void *stream_new(struct session *sess, struct stconn *sc, struct buffer *input);
 void stream_free(struct stream *s);
 int stream_upgrade_from_sc(struct stconn *sc, struct buffer *input);
 int stream_set_http_mode(struct stream *s, const struct mux_proto_list *mux_proto);
index 778c9d9e4556d89268c66a11bec2551b9793ac0c..21de08acf3912e4c077975c4bd13ebf5ab78bb9f 100644 (file)
@@ -1578,6 +1578,7 @@ void init_new_proxy(struct proxy *p)
        /* Default to only allow L4 retries */
        p->retry_type = PR_RE_CONN_FAILED;
 
+       p->stream_new_from_sc = stream_new;
        guid_init(&p->guid);
 
        p->extra_counters_fe = NULL;
@@ -3343,6 +3344,7 @@ static int proxy_defproxy_cpy(struct proxy *curproxy, const struct proxy *defpro
                curproxy->clitcpka_cnt   = defproxy->clitcpka_cnt;
                curproxy->clitcpka_idle  = defproxy->clitcpka_idle;
                curproxy->clitcpka_intvl = defproxy->clitcpka_intvl;
+               curproxy->stream_new_from_sc = defproxy->stream_new_from_sc;
        }
 
        if (curproxy->cap & PR_CAP_BE) {
index 770722d1320a56de065c3b38e87943bb5cfb1d72..3f0c264af4c2733db70814a95efd13939cddb5ff 100644 (file)
@@ -244,7 +244,7 @@ struct stconn *sc_new_from_endp(struct sedesc *sd, struct session *sess, struct
        sc = sc_new(sd);
        if (unlikely(!sc))
                return NULL;
-       if (unlikely(!stream_new(sess, sc, input))) {
+       if (unlikely(!sess->fe->stream_new_from_sc(sess, sc, input))) {
                sd->sc = NULL;
                if (sc->sedesc != sd) {
                        /* none was provided so sc_new() allocated one */
index 63cbade0a4ee0e86c0e64670d76359e6d4dfe0c8..b2eef9187f5dc63ecd61dda391582c0db3974e40 100644 (file)
@@ -344,7 +344,7 @@ int stream_buf_available(void *arg)
  * transfer to the stream and <input> is set to BUF_NULL. On error, <input>
  * buffer is unchanged and it is the caller responsibility to release it.
  */
-struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer *input)
+void *stream_new(struct session *sess, struct stconn *sc, struct buffer *input)
 {
        struct stream *s;
        struct task *t;