]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: connection: use conn_xprt_ready() instead of checking the flag
authorWilly Tarreau <w@1wt.eu>
Thu, 23 Jan 2014 13:21:42 +0000 (14:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 25 Jan 2014 23:42:31 +0000 (00:42 +0100)
It's easier and safer to rely on conn_xprt_ready() everywhere than to
check the flag itself. It will also simplify adding extra checks later
if needed. Some useless controls for !xprt have been removed, as the
XPRT_READY flag itself guarantees xprt is set.

include/proto/connection.h
src/dumpstats.c

index 97abe3fe3313e4169605a3a9411acfa4b2862e07..8609f1774c81ad25b51782c5ef8409a8047ef6fb 100644 (file)
@@ -44,9 +44,9 @@ int conn_recv_proxy(struct connection *conn, int flag);
 int make_proxy_line(char *buf, int buf_len, struct sockaddr_storage *src, struct sockaddr_storage *dst);
 
 /* returns true is the transport layer is ready */
-static inline int conn_xprt_ready(struct connection *conn)
+static inline int conn_xprt_ready(const struct connection *conn)
 {
-       return (conn->flags & CO_FL_XPRT_READY) && conn->xprt;
+       return (conn->flags & CO_FL_XPRT_READY);
 }
 
 /* returns true is the control layer is ready */
@@ -63,7 +63,7 @@ static inline int conn_xprt_init(struct connection *conn)
 {
        int ret = 0;
 
-       if (!(conn->flags & CO_FL_XPRT_READY) && conn->xprt && conn->xprt->init)
+       if (!conn_xprt_ready(conn) && conn->xprt && conn->xprt->init)
                ret = conn->xprt->init(conn);
 
        if (ret >= 0)
@@ -80,7 +80,7 @@ static inline int conn_xprt_init(struct connection *conn)
 static inline void conn_xprt_close(struct connection *conn)
 {
        if ((conn->flags & (CO_FL_XPRT_READY|CO_FL_XPRT_TRACKED)) == CO_FL_XPRT_READY) {
-               if (conn->xprt && conn->xprt->close)
+               if (conn->xprt->close)
                        conn->xprt->close(conn);
                conn->flags &= ~CO_FL_XPRT_READY;
        }
@@ -135,7 +135,7 @@ static inline void conn_full_close(struct connection *conn)
  */
 static inline void conn_force_close(struct connection *conn)
 {
-       if ((conn->flags & CO_FL_XPRT_READY) && conn->xprt && conn->xprt->close)
+       if (conn_xprt_ready(conn) && conn->xprt->close)
                conn->xprt->close(conn);
 
        if (conn_ctrl_ready(conn))
index 18aadf64087cdc762f37eee5efb12bfedf50ee57..40b02876851f2edda76b0468b41478280a05fe46 100644 (file)
@@ -4295,7 +4295,7 @@ static inline const char *get_conn_xprt_name(const struct connection *conn)
 {
        static char ptr[17];
 
-       if (!(conn->flags & CO_FL_XPRT_READY) || !conn->xprt)
+       if (!conn_xprt_ready(conn))
                return "NONE";
 
        if (conn->xprt == &raw_sock)