]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: connection: send data before receiving
authorWilly Tarreau <w@1wt.eu>
Tue, 11 Apr 2017 17:59:33 +0000 (19:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 27 Jun 2017 12:38:02 +0000 (14:38 +0200)
It's more efficient this way, as it allows to flush a send buffer before
receiving data in the other one. This can lead to a slightly faster buffer
recycling, thus slightly less memory and a small performance increase by
using a hotter cache.

src/connection.c

index f054cd13b7fedc5e8a849fff5f97821a74a02d05..0c90c3b43743367a4582dba5e32c05c960771dc4 100644 (file)
@@ -94,28 +94,28 @@ void conn_fd_handler(int fd)
        if ((conn->flags & CO_FL_INIT_DATA) && conn->data->init(conn) < 0)
                return;
 
-       /* The data transfer starts here and stops on error and handshakes. Note
-        * that we must absolutely test conn->xprt at each step in case it suddenly
-        * changes due to a quick unexpected close().
-        */
-       if (conn->xprt && fd_recv_ready(fd) &&
-           ((conn->flags & (CO_FL_DATA_RD_ENA|CO_FL_WAIT_ROOM|CO_FL_ERROR|CO_FL_HANDSHAKE)) == CO_FL_DATA_RD_ENA)) {
+       if (conn->xprt && fd_send_ready(fd) &&
+           ((conn->flags & (CO_FL_DATA_WR_ENA|CO_FL_ERROR|CO_FL_HANDSHAKE)) == CO_FL_DATA_WR_ENA)) {
                /* force reporting of activity by clearing the previous flags :
                 * we'll have at least ERROR or CONNECTED at the end of an I/O,
                 * both of which will be detected below.
                 */
                flags = 0;
-               conn->data->recv(conn);
+               conn->data->send(conn);
        }
 
-       if (conn->xprt && fd_send_ready(fd) &&
-           ((conn->flags & (CO_FL_DATA_WR_ENA|CO_FL_ERROR|CO_FL_HANDSHAKE)) == CO_FL_DATA_WR_ENA)) {
+       /* The data transfer starts here and stops on error and handshakes. Note
+        * that we must absolutely test conn->xprt at each step in case it suddenly
+        * changes due to a quick unexpected close().
+        */
+       if (conn->xprt && fd_recv_ready(fd) &&
+           ((conn->flags & (CO_FL_DATA_RD_ENA|CO_FL_WAIT_ROOM|CO_FL_ERROR|CO_FL_HANDSHAKE)) == CO_FL_DATA_RD_ENA)) {
                /* force reporting of activity by clearing the previous flags :
                 * we'll have at least ERROR or CONNECTED at the end of an I/O,
                 * both of which will be detected below.
                 */
                flags = 0;
-               conn->data->send(conn);
+               conn->data->recv(conn);
        }
 
        /* It may happen during the data phase that a handshake is