return (c->flags & (CO_FL_DATA_WR_SH | CO_FL_SOCK_WR_SH)) == CO_FL_DATA_WR_SH;
}
+/* prepares a connection to work with protocol <proto> and transport <xprt>.
+ * The transport's context is initialized as well.
+ */
+static inline void conn_prepare(struct connection *conn, const struct protocol *proto, const struct xprt_ops *xprt)
+{
+ conn->ctrl = proto;
+ conn->xprt = xprt;
+ conn->xprt_st = 0;
+ conn->xprt_ctx = NULL;
+}
+
/* Initializes all required fields for a new connection. Note that it does the
* minimum acceptable initialization for a connection that already exists and
* is about to be reused. It also leaves the addresses untouched, which makes
{
conn->obj_type = OBJ_TYPE_CONN;
conn->flags = CO_FL_NONE;
- conn->xprt_st = 0;
- conn->xprt_ctx = NULL;
conn->data = NULL;
conn->owner = NULL;
conn->t.sock.fd = -1; /* just to help with debugging */
/* prepare a new connection */
conn_init(conn);
+ conn_prepare(conn, s->check_common.proto, s->check_common.xprt);
conn_assign(conn, &check_conn_cb, s->check_common.proto, s->check_common.xprt, check);
conn->target = &s->obj_type;
*/
conn_init(cli_conn);
cli_conn->t.sock.fd = cfd;
- cli_conn->ctrl = l->proto;
cli_conn->flags |= CO_FL_ADDR_FROM_SET;
+ conn_prepare(cli_conn, l->proto, l->xprt);
cli_conn->addr.from = *addr;
cli_conn->target = &l->obj_type;