]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream-int/backend: Move si_connect() in the backend scope
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 31 Mar 2022 07:53:38 +0000 (09:53 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 13 Apr 2022 13:10:15 +0000 (15:10 +0200)
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.

include/haproxy/stream_interface.h
src/backend.c

index 0085de8efc4a4d030ed63454068511b445e22a48..dbe11985e16c84635883b4d5937438a2e88e81e9 100644 (file)
@@ -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)
 {
index 928c213fc5bdbd91d6215e9d01a043fc70e41706..ea27b8c4a0c223a140ecec1aecce64b21ef7d4cc 100644 (file)
@@ -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;