From: Willy Tarreau Date: Tue, 2 Oct 2012 18:57:19 +0000 (+0200) Subject: MINOR: connection: split conn_prepare() in two functions X-Git-Tag: v1.5-dev13~218 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd99aab91f26dfb1ff336bab5682b77829c568d5;p=thirdparty%2Fhaproxy.git MINOR: connection: split conn_prepare() in two functions We'll also need a function to takeover an existing connection without reinitializing it. The same will be needed at the stream interface level. --- diff --git a/include/proto/connection.h b/include/proto/connection.h index f43525fb29..2c93ccf900 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -412,17 +412,25 @@ static inline void conn_get_to_addr(struct connection *conn) conn->flags |= CO_FL_ADDR_TO_SET; } -/* prepares a connection with the appropriate data, ctrl and transport layers. - * The data state and context are set to 0, and the connection's owner is set. - */ -static inline void conn_prepare(struct connection *conn, const struct data_cb *data, - const struct protocol *ctrl, const struct xprt_ops *xprt, - void *owner) +/* Assigns a connection with the appropriate data, ctrl, transport layers, and owner. */ +static inline void conn_assign(struct connection *conn, const struct data_cb *data, + const struct protocol *ctrl, const struct xprt_ops *xprt, + void *owner) { conn->data = data; conn->ctrl = ctrl; conn->xprt = xprt; conn->owner = owner; +} + +/* prepares a connection with the appropriate data, ctrl, transport layers, and + * owner. The transport state and context are set to 0. + */ +static inline void conn_prepare(struct connection *conn, const struct data_cb *data, + const struct protocol *ctrl, const struct xprt_ops *xprt, + void *owner) +{ + conn_assign(conn, data, ctrl, xprt, owner); conn->xprt_st = 0; conn->xprt_ctx = NULL; } diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index bf03f6e1c0..b0a65fa1a0 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -67,6 +67,12 @@ static inline void si_prepare_conn(struct stream_interface *si, const struct pro conn_prepare(&si->conn, &si_conn_cb, ctrl, xprt, si); } +static inline void si_takeover_conn(struct stream_interface *si, const struct protocol *ctrl, const struct xprt_ops *xprt) +{ + si->ops = &si_conn_ops; + conn_assign(&si->conn, &si_conn_cb, ctrl, xprt, si); +} + static inline void si_prepare_embedded(struct stream_interface *si) { si->ops = &si_embedded_ops;