]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: split conn_prepare() in two functions
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Oct 2012 18:57:19 +0000 (20:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 4 Oct 2012 20:26:10 +0000 (22:26 +0200)
We'll also need a function to takeover an existing connection without
reinitializing it. The same will be needed at the stream interface level.

include/proto/connection.h
include/proto/stream_interface.h

index f43525fb29b04f955c3645bfec1bdd76fbcfa642..2c93ccf900be554cde51155e0b60057fa9c486be 100644 (file)
@@ -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;
 }
index bf03f6e1c036746d0aa3915a6332d7431a4d74e8..b0a65fa1a0113a2e520101b288964776abe4a280 100644 (file)
@@ -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;