MINOR: stconn: stream instantiation from proxy callback

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.
This commit is contained in:
Frederic Lecaille 2026-02-11 14:43:58 +01:00 committed by Willy Tarreau
parent 1dc20a630a
commit 2bf091e9da
5 changed files with 6 additions and 3 deletions

View 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;

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

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

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

View 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;