MINOR: connection: pass the proxy when creating a connection
Till now it was very difficult for a mux to know what proxy it was
working for. Let's pass the proxy when the mux is instanciated at
init() time. It's not yet used but the H1 mux will definitely need
it, just like the H2 mux when dealing with backend connections.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 2a45677..85c5b63 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -796,11 +796,12 @@
/* Installs the connection's mux layer for upper context <ctx>.
* Returns < 0 on error.
*/
-static inline int conn_install_mux(struct connection *conn, const struct mux_ops *mux, void *ctx)
+static inline int conn_install_mux(struct connection *conn, const struct mux_ops *mux,
+ void *ctx, struct proxy *prx)
{
conn->mux = mux;
conn->mux_ctx = ctx;
- return mux->init ? mux->init(conn) : 0;
+ return mux->init ? mux->init(conn, prx) : 0;
}
/* returns a human-readable error code for conn->err_code, or NULL if the code
@@ -1045,7 +1046,7 @@
if (!mux_ops)
return -1;
}
- return conn_install_mux(conn, mux_ops, ctx);
+ return conn_install_mux(conn, mux_ops, ctx, bind_conf->frontend);
}
/* installs the best mux for outgoing connection <conn> using the upper context
@@ -1074,7 +1075,7 @@
if (!mux_ops)
return -1;
}
- return conn_install_mux(conn, mux_ops, ctx);
+ return conn_install_mux(conn, mux_ops, ctx, prx);
}
#endif /* _PROTO_CONNECTION_H */
diff --git a/include/types/connection.h b/include/types/connection.h
index 59bb27d..27ae76e 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -41,6 +41,7 @@
struct connection;
struct conn_stream;
struct buffer;
+struct proxy;
struct server;
struct pipe;
@@ -310,7 +311,7 @@
* layer is not ready yet.
*/
struct mux_ops {
- int (*init)(struct connection *conn); /* early initialization */
+ int (*init)(struct connection *conn, struct proxy *prx); /* early initialization */
int (*wake)(struct connection *conn); /* mux-layer callback to report activity, mandatory */
void (*update_poll)(struct conn_stream *cs); /* commit cs flags to mux/conn */
size_t (*rcv_buf)(struct conn_stream *cs, struct buffer *buf, size_t count, int flags); /* Called from the upper layer to get data */
diff --git a/src/checks.c b/src/checks.c
index 9637430..6d19eef 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -1611,7 +1611,7 @@
clear_addr(&conn->addr.from);
conn_prepare(conn, proto, check->xprt);
- conn_install_mux(conn, &mux_pt_ops, cs);
+ conn_install_mux(conn, &mux_pt_ops, cs, s->proxy);
cs_attach(cs, check, &check_conn_cb);
/* only plain tcp-check supports quick ACK */
@@ -2806,7 +2806,7 @@
}
conn_prepare(conn, proto, xprt);
- conn_install_mux(conn, &mux_pt_ops, cs);
+ conn_install_mux(conn, &mux_pt_ops, cs, s->proxy);
cs_attach(cs, check, &check_conn_cb);
ret = SF_ERR_INTERNAL;
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 780bc57..3faf5ae 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -438,7 +438,7 @@
* connections from the fact that the context is still NULL. Returns < 0 on
* error.
*/
-static int h2_init(struct connection *conn)
+static int h2_init(struct connection *conn, struct proxy *prx)
{
if (conn->mux_ctx) {
/* we don't support outgoing connections for now */
diff --git a/src/mux_pt.c b/src/mux_pt.c
index 466ac21..5b86419 100644
--- a/src/mux_pt.c
+++ b/src/mux_pt.c
@@ -19,7 +19,7 @@
* incoming ones, in which case one will be allocated and a new stream will be
* instanciated). Returns < 0 on error.
*/
-static int mux_pt_init(struct connection *conn)
+static int mux_pt_init(struct connection *conn, struct proxy *prx)
{
struct conn_stream *cs = conn->mux_ctx;
diff --git a/src/peers.c b/src/peers.c
index 50aee87..e61caaf 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1971,7 +1971,7 @@
memcpy(&conn->addr.to, &peer->addr, sizeof(conn->addr.to));
conn_prepare(conn, peer->proto, peer->xprt);
- conn_install_mux(conn, &mux_pt_ops, cs);
+ conn_install_mux(conn, &mux_pt_ops, cs, s->be);
si_attach_cs(&s->si[1], cs);
s->do_log = NULL;