MEDIUM: connection: avoid calling handshakes when polling is required

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.
This commit is contained in:
Willy Tarreau 2012-09-02 18:48:46 +02:00
parent 56a77e5933
commit d9de7ca3d0

View 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))