From: Christopher Faulet Date: Thu, 16 Dec 2021 13:41:44 +0000 (+0100) Subject: MINOR: stream-int: Add function to attach a connection to a SI X-Git-Tag: v2.6-dev2~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a3b598b478170b385c632d5ca1d4506e329ad80;p=thirdparty%2Fhaproxy.git MINOR: stream-int: Add function to attach a connection to a SI si_attach_conn() function should be used to attach a connection to a stream-interface. It created a conn-stream if necessary. This function is mandatory to be able to keep the backend conn-stream during connection retries. --- diff --git a/include/haproxy/stream_interface.h b/include/haproxy/stream_interface.h index dec91f2b38..acc22e756c 100644 --- a/include/haproxy/stream_interface.h +++ b/include/haproxy/stream_interface.h @@ -229,6 +229,23 @@ static inline void si_attach_cs(struct stream_interface *si, struct conn_stream cs_attach(cs, si, &si_conn_cb); } +static inline struct conn_stream *si_attach_conn(struct stream_interface *si, struct connection *conn) +{ + struct conn_stream *cs; + + si_reset_endpoint(si); + cs = objt_cs(si->end); + if (!cs) + cs = cs_new(conn, conn->target); + if (cs) { + cs_init(cs, conn); + if (!conn->ctx) + conn->ctx = cs; + si_attach_cs(si, cs); + } + return cs; +} + /* Returns true if a connection is attached to the stream interface and * if this connection is ready. */