CLEANUP: stconn: rename cs_conn_get_first() to conn_get_first_sc()

It returns an stconn from a connection and not the opposite, so the name
change was more appropriate. In addition it was moved to connection.h
which manipulates the connection stuff, and it happens that only
connection.c uses it.
This commit is contained in:
Willy Tarreau 2022-05-18 18:11:27 +02:00
parent 462b989d4c
commit 108423819c
3 changed files with 19 additions and 20 deletions

View file

@ -283,25 +283,6 @@ static inline void cs_ep_set_error(struct sedesc *endp)
se_fl_set(endp, SE_FL_ERR_PENDING);
}
/* Retrieves any valid stream connector from this connection, preferably the first
* valid one. The purpose is to be able to figure one other end of a private
* connection for purposes like source binding or proxy protocol header
* emission. In such cases, any stream connector is expected to be valid so the
* mux is encouraged to return the first one it finds. If the connection has
* no mux or the mux has no get_first_cs() method or the mux has no valid
* stream connector, NULL is returned. The output pointer is purposely marked
* const to discourage the caller from modifying anything there.
*/
static inline struct stconn *cs_conn_get_first(const struct connection *conn)
{
BUG_ON(!conn || !conn->mux);
if (!conn->mux->get_first_cs)
return NULL;
return conn->mux->get_first_cs(conn);
}
/* Returns non-zero if the stream connector's Rx path is blocked */
static inline int cs_rx_blocked(const struct stconn *cs)
{

View file

@ -493,6 +493,24 @@ static inline int conn_install_mux(struct connection *conn, const struct mux_ops
return ret;
}
/* Retrieves any valid stream connector from this connection, preferably the first
* valid one. The purpose is to be able to figure one other end of a private
* connection for purposes like source binding or proxy protocol header
* emission. In such cases, any stream connector is expected to be valid so the
* mux is encouraged to return the first one it finds. If the connection has
* no mux or the mux has no get_first_cs() method or the mux has no valid
* stream connector, NULL is returned. The output pointer is purposely marked
* const to discourage the caller from modifying anything there.
*/
static inline struct stconn *conn_get_first_sc(const struct connection *conn)
{
BUG_ON(!conn || !conn->mux);
if (!conn->mux->get_first_cs)
return NULL;
return conn->mux->get_first_cs(conn);
}
int conn_update_alpn(struct connection *conn, const struct ist alpn, int force);
static inline const char *conn_get_ctrl_name(const struct connection *conn)

View file

@ -1176,7 +1176,7 @@ int conn_send_proxy(struct connection *conn, unsigned int flag)
/* If there is no mux attached to the connection, it means the
* connection context is a stream connector.
*/
cs = (conn->mux ? cs_conn_get_first(conn) : conn->ctx);
cs = conn->mux ? conn_get_first_sc(conn) : conn->ctx;
/* The target server expects a PROXY line to be sent first.
* If the send_proxy_ofs is negative, it corresponds to the