MINOR: connection: send data before receiving

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.
This commit is contained in:
Willy Tarreau 2017-04-11 19:59:33 +02:00
parent d62b98c6e8
commit 57ec32fb99

View File

@ -94,6 +94,16 @@ void conn_fd_handler(int fd)
if ((conn->flags & CO_FL_INIT_DATA) && conn->data->init(conn) < 0) if ((conn->flags & CO_FL_INIT_DATA) && conn->data->init(conn) < 0)
return; return;
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->send(conn);
}
/* The data transfer starts here and stops on error and handshakes. Note /* 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 * that we must absolutely test conn->xprt at each step in case it suddenly
* changes due to a quick unexpected close(). * changes due to a quick unexpected close().
@ -108,16 +118,6 @@ void conn_fd_handler(int fd)
conn->data->recv(conn); conn->data->recv(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)) {
/* 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);
}
/* It may happen during the data phase that a handshake is /* It may happen during the data phase that a handshake is
* enabled again (eg: SSL) * enabled again (eg: SSL)
*/ */