/* prepares a connection to work with protocol <proto> and transport <xprt>.
* The transport's is initialized as well, and the mux and its context are
- * cleared.
+ * cleared. The target is not reinitialized and it is recommended that it is
+ * set prior to calling this function so that the function may make use of it
+ * in the future to refine the mux choice if needed.
*/
static inline void conn_prepare(struct connection *conn, const struct protocol *proto, const struct xprt_ops *xprt)
{
}
proto = protocol_by_family(conn->addr.to.ss_family);
-
- conn_prepare(conn, proto, check->xprt);
- conn_install_mux(conn, &mux_pt_ops, cs);
- cs_attach(cs, check, &check_conn_cb);
conn->target = &s->obj_type;
- if ((conn->addr.to.ss_family == AF_INET) || (conn->addr.to.ss_family == AF_INET6)) {
+ if ((conn->addr.to.ss_family == AF_INET) || (conn->addr.to.ss_family == AF_INET6)) {
int i = 0;
i = srv_check_healthcheck_port(check);
/* no client address */
clear_addr(&conn->addr.from);
+ conn_prepare(conn, proto, check->xprt);
+ conn_install_mux(conn, &mux_pt_ops, cs);
+ cs_attach(cs, check, &check_conn_cb);
+
/* only plain tcp-check supports quick ACK */
quickack = check->type == 0 || check->type == PR_O2_TCPCHK_CHK;
check->cs = cs;
conn = cs->conn;
- cs_attach(cs, check, &check_conn_cb);
conn->target = &s->obj_type;
/* no client address */
else {
xprt = xprt_get(XPRT_RAW);
}
+
conn_prepare(conn, proto, xprt);
conn_install_mux(conn, &mux_pt_ops, cs);
+ cs_attach(cs, check, &check_conn_cb);
ret = SF_ERR_INTERNAL;
if (proto->connect)
if (unlikely((cs = cs_new(conn)) == NULL))
goto out_free_conn;
+ conn->target = s->target = &s->be->obj_type;
+ 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);
si_attach_cs(&s->si[1], cs);
- conn->target = s->target = &s->be->obj_type;
- memcpy(&conn->addr.to, &peer->addr, sizeof(conn->addr.to));
s->do_log = NULL;
s->uniq_id = 0;
if (unlikely((cli_conn = conn_new()) == NULL))
goto out_close;
- conn_prepare(cli_conn, l->proto, l->bind_conf->xprt);
-
cli_conn->handle.fd = cfd;
cli_conn->addr.from = *addr;
cli_conn->flags |= CO_FL_ADDR_FROM_SET;
cli_conn->target = &l->obj_type;
cli_conn->proxy_netns = l->netns;
+ conn_prepare(cli_conn, l->proto, l->bind_conf->xprt);
conn_ctrl_init(cli_conn);
/* wait for a PROXY protocol header */