From: Willy Tarreau Date: Wed, 18 May 2022 16:11:27 +0000 (+0200) Subject: CLEANUP: stconn: rename cs_conn_get_first() to conn_get_first_sc() X-Git-Tag: v2.6-dev12~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=108423819c6d2bf32e5aca70918ff4158e878dc7;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/conn_stream.h b/include/haproxy/conn_stream.h index 112b27e2a3..e3d2b71f79 100644 --- a/include/haproxy/conn_stream.h +++ b/include/haproxy/conn_stream.h @@ -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) { diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h index 30e689e155..34d3f70d7d 100644 --- a/include/haproxy/connection.h +++ b/include/haproxy/connection.h @@ -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) diff --git a/src/connection.c b/src/connection.c index f3775e85f6..7ba4b17cd2 100644 --- a/src/connection.c +++ b/src/connection.c @@ -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