]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int: Add function to attach a connection to a SI
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 16 Dec 2021 13:41:44 +0000 (14:41 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Feb 2022 10:00:02 +0000 (11:00 +0100)
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.

include/haproxy/stream_interface.h

index dec91f2b384a688f4206842d4d7526412ec7a11d..acc22e756cc71cb92ec8f422bfb4cf40ca294e4d 100644 (file)
@@ -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 <si> and
  * if this connection is ready.
  */