From: Christopher Faulet Date: Thu, 31 Mar 2022 07:53:38 +0000 (+0200) Subject: MINOR: stream-int/backend: Move si_connect() in the backend scope X-Git-Tag: v2.6-dev6~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a4dcb65ff9f5215115c8c12be3a77217eeff255;p=thirdparty%2Fhaproxy.git MINOR: stream-int/backend: Move si_connect() in the backend scope si_connect() is moved in backend.c and renamed as do_connect_server(). In addition, the function now manipulate a stream instead of a stream-interface. --- diff --git a/include/haproxy/stream_interface.h b/include/haproxy/stream_interface.h index 0085de8efc..dbe11985e1 100644 --- a/include/haproxy/stream_interface.h +++ b/include/haproxy/stream_interface.h @@ -328,45 +328,6 @@ static inline void si_chk_snd(struct stream_interface *si) si->ops->chk_snd(si); } -/* Calls chk_snd on the connection using the ctrl layer */ -static inline int si_connect(struct stream_interface *si, struct connection *conn) -{ - int ret = SF_ERR_NONE; - int conn_flags = 0; - - if (unlikely(!conn || !conn->ctrl || !conn->ctrl->connect)) - return SF_ERR_INTERNAL; - - if (!channel_is_empty(si_oc(si))) - conn_flags |= CONNECT_HAS_DATA; - if (si_strm(si)->conn_retries == si_strm(si)->be->conn_retries) - conn_flags |= CONNECT_CAN_USE_TFO; - if (!conn_ctrl_ready(conn) || !conn_xprt_ready(conn)) { - ret = conn->ctrl->connect(conn, conn_flags); - if (ret != SF_ERR_NONE) - return ret; - - /* we're in the process of establishing a connection */ - si->cs->state = CS_ST_CON; - } - else { - /* try to reuse the existing connection, it will be - * confirmed once we can send on it. - */ - /* Is the connection really ready ? */ - if (conn->mux->ctl(conn, MUX_STATUS, NULL) & MUX_STATUS_READY) - si->cs->state = CS_ST_RDY; - else - si->cs->state = CS_ST_CON; - } - - /* needs src ip/port for logging */ - if (si_strm(si)->flags & SF_SRC_ADDR) - conn_get_src(conn); - - return ret; -} - /* Combines both si_update_rx() and si_update_tx() at once */ static inline void si_update(struct stream_interface *si) { diff --git a/src/backend.c b/src/backend.c index 928c213fc5..ea27b8c4a0 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1234,6 +1234,44 @@ static struct connection *conn_backend_get(struct stream *s, struct server *srv, return conn; } +static int do_connect_server(struct stream *s, struct connection *conn) +{ + int ret = SF_ERR_NONE; + int conn_flags = 0; + + if (unlikely(!conn || !conn->ctrl || !conn->ctrl->connect)) + return SF_ERR_INTERNAL; + + if (!channel_is_empty(&s->res)) + conn_flags |= CONNECT_HAS_DATA; + if (s->conn_retries == s->be->conn_retries) + conn_flags |= CONNECT_CAN_USE_TFO; + if (!conn_ctrl_ready(conn) || !conn_xprt_ready(conn)) { + ret = conn->ctrl->connect(conn, conn_flags); + if (ret != SF_ERR_NONE) + return ret; + + /* we're in the process of establishing a connection */ + s->csb->state = CS_ST_CON; + } + else { + /* try to reuse the existing connection, it will be + * confirmed once we can send on it. + */ + /* Is the connection really ready ? */ + if (conn->mux->ctl(conn, MUX_STATUS, NULL) & MUX_STATUS_READY) + s->csb->state = CS_ST_RDY; + else + s->csb->state = CS_ST_CON; + } + + /* needs src ip/port for logging */ + if (s->flags & SF_SRC_ADDR) + conn_get_src(conn); + + return ret; +} + /* * This function initiates a connection to the server assigned to this stream * (s->target, (s->csb->si)->addr.to). It will assign a server if none @@ -1653,7 +1691,7 @@ skip_reuse: _HA_ATOMIC_INC(&srv->counters.connect); } - err = si_connect(cs_si(s->csb), srv_conn); + err = do_connect_server(s, srv_conn); if (err != SF_ERR_NONE) return err;