mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
CLEANUP: connection: offer conn_prepare() to set up a connection
This will be used by checks as well as stream interfaces.
This commit is contained in:
parent
173e7fbd94
commit
dda5e7c986
@ -412,6 +412,18 @@ static inline void conn_get_to_addr(struct connection *conn)
|
|||||||
conn->flags |= CO_FL_ADDR_TO_SET;
|
conn->flags |= CO_FL_ADDR_TO_SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* prepares a connection with the appropriate app_cb, ctrl and data layers. The
|
||||||
|
* data state and context are set to 0.
|
||||||
|
*/
|
||||||
|
static inline void conn_prepare(struct connection *conn, const struct app_cb *app,
|
||||||
|
const struct protocol *ctrl, const struct data_ops *data)
|
||||||
|
{
|
||||||
|
conn->app_cb = app;
|
||||||
|
conn->ctrl = ctrl;
|
||||||
|
conn->data = data;
|
||||||
|
conn->data_st = 0;
|
||||||
|
conn->data_ctx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _PROTO_CONNECTION_H */
|
#endif /* _PROTO_CONNECTION_H */
|
||||||
|
|
||||||
|
@ -67,31 +67,19 @@ static inline int si_fd(struct stream_interface *si)
|
|||||||
static inline void si_prepare_conn(struct stream_interface *si, const struct protocol *ctrl, const struct data_ops *ops)
|
static inline void si_prepare_conn(struct stream_interface *si, const struct protocol *ctrl, const struct data_ops *ops)
|
||||||
{
|
{
|
||||||
si->ops = &si_conn_ops;
|
si->ops = &si_conn_ops;
|
||||||
si->conn.app_cb = &si_conn_cb;
|
conn_prepare(&si->conn, &si_conn_cb, ctrl, ops);
|
||||||
si->conn.ctrl = ctrl;
|
|
||||||
si->conn.data = ops;
|
|
||||||
si->conn.data_st = 0;
|
|
||||||
si->conn.data_ctx = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void si_prepare_embedded(struct stream_interface *si)
|
static inline void si_prepare_embedded(struct stream_interface *si)
|
||||||
{
|
{
|
||||||
si->ops = &si_embedded_ops;
|
si->ops = &si_embedded_ops;
|
||||||
si->conn.app_cb = NULL;
|
conn_prepare(&si->conn, NULL, NULL, NULL);
|
||||||
si->conn.ctrl = NULL;
|
|
||||||
si->conn.data = NULL;
|
|
||||||
si->conn.data_st = 0;
|
|
||||||
si->conn.data_ctx = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void si_prepare_task(struct stream_interface *si)
|
static inline void si_prepare_task(struct stream_interface *si)
|
||||||
{
|
{
|
||||||
si->ops = &si_task_ops;
|
si->ops = &si_task_ops;
|
||||||
si->conn.app_cb = NULL;
|
conn_prepare(&si->conn, NULL, NULL, NULL);
|
||||||
si->conn.ctrl = NULL;
|
|
||||||
si->conn.data = NULL;
|
|
||||||
si->conn.data_st = 0;
|
|
||||||
si->conn.data_ctx = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sends a shutr to the connection using the data layer */
|
/* Sends a shutr to the connection using the data layer */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user