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.
This commit is contained in:
Christopher Faulet
2022-03-31 09:53:38 +02:00
parent 9125f3cc77
commit 0a4dcb65ff
2 changed files with 39 additions and 40 deletions

View 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)
{

View 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;