]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: connection: avoid calling handshakes when polling is required
authorWilly Tarreau <w@1wt.eu>
Sun, 2 Sep 2012 16:48:46 +0000 (18:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 3 Sep 2012 18:47:35 +0000 (20:47 +0200)
If a data handler suddenly switches to a handshake mode and detects the
need for polling in either direction, we don't want to loop again through
the handshake handlers because we know we won't be able to do anything.

Similarly, we don't want to call again the data handlers after a loop
through the handshake handlers if polling is required.

No performance change was observed, it might only be observed during
high rate SSL renegociation.

src/connection.c

index 15b94856ffa48c6c4f277cb03872be0eb615549b..cb314add48bae3bc189ba92b08dc35d6a6cfca99 100644 (file)
@@ -41,7 +41,7 @@ int conn_fd_handler(int fd)
         * work must explicitly disable events it's not interested in.
         */
        while (unlikely(conn->flags & CO_FL_HANDSHAKE)) {
-               if (unlikely(conn->flags & CO_FL_ERROR))
+               if (unlikely(conn->flags & (CO_FL_ERROR|CO_FL_WAIT_RD|CO_FL_WAIT_WR)))
                        goto leave;
 
                if (conn->flags & CO_FL_ACCEPT_PROXY)
@@ -65,7 +65,8 @@ int conn_fd_handler(int fd)
            conn_session_complete(conn, CO_FL_INIT_SESS) < 0)
                return 0;
 
-       if (fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR))
+       if ((fdtab[fd].ev & (FD_POLL_IN | FD_POLL_HUP | FD_POLL_ERR)) &&
+           !(conn->flags & (CO_FL_WAIT_RD|CO_FL_WAIT_ROOM)))
                conn->app_cb->recv(conn);
 
        if (unlikely(conn->flags & CO_FL_ERROR))
@@ -77,7 +78,8 @@ int conn_fd_handler(int fd)
        if (unlikely(conn->flags & CO_FL_HANDSHAKE))
                goto process_handshake;
 
-       if (fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR))
+       if ((fdtab[fd].ev & (FD_POLL_OUT | FD_POLL_ERR)) &&
+           !(conn->flags & (CO_FL_WAIT_WR|CO_FL_WAIT_DATA)))
                conn->app_cb->send(conn);
 
        if (unlikely(conn->flags & CO_FL_ERROR))