]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: improve error handling around the data layer
authorWilly Tarreau <w@1wt.eu>
Thu, 6 Sep 2012 12:12:03 +0000 (14:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Sep 2012 12:12:03 +0000 (14:12 +0200)
Better avoid calling the data functions upon error or handshake than
having to put conditions everywhere, which are too easy to forget (one
check for CO_FL_ERROR was missing, but this was harmless).

src/connection.c

index 90283fc5e320a3c3663e6da1f4a2801fc51b0e00..8966bf70f69d8bdaead7bd9782b9b4a15b87fa16 100644 (file)
@@ -75,21 +75,13 @@ int conn_fd_handler(int fd)
            conn_session_complete(conn, CO_FL_INIT_SESS) < 0)
                return 0;
 
+       /* The data transfer starts here and stops on error and handshakes */
        if ((fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR)) &&
-           !(conn->flags & (CO_FL_WAIT_RD|CO_FL_WAIT_ROOM)))
+           !(conn->flags & (CO_FL_WAIT_RD|CO_FL_WAIT_ROOM|CO_FL_ERROR|CO_FL_HANDSHAKE)))
                conn->app_cb->recv(conn);
 
-       if (unlikely(conn->flags & CO_FL_ERROR))
-               goto leave;
-
-       /* It may happen during the data phase that a handshake is
-        * enabled again (eg: SSL)
-        */
-       if (unlikely(conn->flags & CO_FL_HANDSHAKE))
-               goto process_handshake;
-
        if ((fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR)) &&
-           !(conn->flags & (CO_FL_WAIT_WR|CO_FL_WAIT_DATA)))
+           !(conn->flags & (CO_FL_WAIT_WR|CO_FL_WAIT_DATA|CO_FL_ERROR|CO_FL_HANDSHAKE)))
                conn->app_cb->send(conn);
 
        if (unlikely(conn->flags & CO_FL_ERROR))