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.
This commit is contained in:
Christopher Faulet 2021-12-16 14:41:44 +01:00
parent 20a6501051
commit 1a3b598b47

View 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.
*/