mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: connection: add alternative mux_ops param for conn_install_mux_be
Add a new parameter force_mux_ops. This will be useful to specify an alternative to the srv->mux_proto field. If non-NULL, it will be use to force the mux protocol wether srv->mux_proto is set or not. This argument will become useful to install a mux for non-standard streams, most notably websocket streams.
This commit is contained in:
parent
2454bda140
commit
ac03ef26e8
@ -76,7 +76,8 @@ int conn_notify_mux(struct connection *conn, int old_flags, int forced_wake);
|
|||||||
int conn_upgrade_mux_fe(struct connection *conn, void *ctx, struct buffer *buf,
|
int conn_upgrade_mux_fe(struct connection *conn, void *ctx, struct buffer *buf,
|
||||||
struct ist mux_proto, int mode);
|
struct ist mux_proto, int mode);
|
||||||
int conn_install_mux_fe(struct connection *conn, void *ctx);
|
int conn_install_mux_fe(struct connection *conn, void *ctx);
|
||||||
int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess);
|
int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess,
|
||||||
|
const struct mux_ops *force_mux_ops);
|
||||||
int conn_install_mux_chk(struct connection *conn, void *ctx, struct session *sess);
|
int conn_install_mux_chk(struct connection *conn, void *ctx, struct session *sess);
|
||||||
|
|
||||||
void conn_delete_from_tree(struct ebmb_node *node);
|
void conn_delete_from_tree(struct ebmb_node *node);
|
||||||
|
@ -1645,7 +1645,7 @@ skip_reuse:
|
|||||||
* fail, and flag the connection as CO_FL_ERROR.
|
* fail, and flag the connection as CO_FL_ERROR.
|
||||||
*/
|
*/
|
||||||
if (init_mux) {
|
if (init_mux) {
|
||||||
if (conn_install_mux_be(srv_conn, srv_cs, s->sess) < 0) {
|
if (conn_install_mux_be(srv_conn, srv_cs, s->sess, NULL) < 0) {
|
||||||
conn_full_close(srv_conn);
|
conn_full_close(srv_conn);
|
||||||
return SF_ERR_INTERNAL;
|
return SF_ERR_INTERNAL;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ int conn_create_mux(struct connection *conn)
|
|||||||
if (conn_install_mux_chk(conn, conn->ctx, sess) < 0)
|
if (conn_install_mux_chk(conn, conn->ctx, sess) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (conn_install_mux_be(conn, conn->ctx, sess) < 0)
|
else if (conn_install_mux_be(conn, conn->ctx, sess, NULL) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
srv = objt_server(conn->target);
|
srv = objt_server(conn->target);
|
||||||
|
|
||||||
@ -247,10 +247,14 @@ int conn_install_mux_fe(struct connection *conn, void *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* installs the best mux for outgoing connection <conn> using the upper context
|
/* installs the best mux for outgoing connection <conn> using the upper context
|
||||||
* <ctx>. If the mux protocol is forced, we use it to find the best mux. Returns
|
* <ctx>. If the server mux protocol is forced, we use it to find the best mux.
|
||||||
* < 0 on error.
|
* It's also possible to specify an alternative mux protocol <force_mux_ops>,
|
||||||
|
* in which case it will be used instead of the default server mux protocol.
|
||||||
|
*
|
||||||
|
* Returns < 0 on error.
|
||||||
*/
|
*/
|
||||||
int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess)
|
int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess,
|
||||||
|
const struct mux_ops *force_mux_ops)
|
||||||
{
|
{
|
||||||
struct server *srv = objt_server(conn->target);
|
struct server *srv = objt_server(conn->target);
|
||||||
struct proxy *prx = objt_proxy(conn->target);
|
struct proxy *prx = objt_proxy(conn->target);
|
||||||
@ -262,8 +266,12 @@ int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess
|
|||||||
if (!prx) // target must be either proxy or server
|
if (!prx) // target must be either proxy or server
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (srv && srv->mux_proto)
|
if (srv && srv->mux_proto && likely(!force_mux_ops)) {
|
||||||
mux_ops = srv->mux_proto->mux;
|
mux_ops = srv->mux_proto->mux;
|
||||||
|
}
|
||||||
|
else if (srv && unlikely(force_mux_ops)) {
|
||||||
|
mux_ops = force_mux_ops;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
struct ist mux_proto;
|
struct ist mux_proto;
|
||||||
const char *alpn_str = NULL;
|
const char *alpn_str = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user