mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-15 21:59:41 -04:00
MINOR: connection: check for connection validation earlier
In conn_fd_handler() we used to first give a chance to the send() callback to try to send data and validate the connection at the same time. But since 1.9 we do not call this callback anymore inline, it's scheduled. So let's validate the connection ealier so that all other decisions can be taken based on this confirmation. This may notably be useful to the xprt_done_cb() to know that the connection was properly validated.
This commit is contained in:
parent
4970e5adb7
commit
b2a7ab08a8
1 changed files with 15 additions and 13 deletions
|
|
@ -60,6 +60,21 @@ void conn_fd_handler(int fd)
|
|||
|
||||
flags = conn->flags & ~CO_FL_ERROR; /* ensure to call the wake handler upon error */
|
||||
|
||||
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) &&
|
||||
((fd_send_ready(fd) && fd_send_active(fd)) ||
|
||||
(fd_recv_ready(fd) && fd_recv_active(fd)))) {
|
||||
/* Still waiting for a connection to establish and nothing was
|
||||
* attempted yet to probe the connection. this will clear the
|
||||
* CO_FL_WAIT_L4_CONN flag on success.
|
||||
*/
|
||||
if (!conn_fd_check(conn))
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* Verify if the connection just established. */
|
||||
if (unlikely(!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN | CO_FL_CONNECTED))))
|
||||
conn->flags |= CO_FL_CONNECTED;
|
||||
|
||||
/* The connection owner might want to be notified about an end of
|
||||
* handshake indicating the connection is ready, before we proceed with
|
||||
* any data exchange. The callback may fail and cause the connection to
|
||||
|
|
@ -86,15 +101,6 @@ void conn_fd_handler(int fd)
|
|||
__conn_xprt_stop_send(conn);
|
||||
}
|
||||
|
||||
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN)) {
|
||||
/* still waiting for a connection to establish and nothing was
|
||||
* attempted yet to probe the connection. Then let's retry the
|
||||
* connect().
|
||||
*/
|
||||
if (!conn_fd_check(conn))
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* 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().
|
||||
|
|
@ -115,10 +121,6 @@ void conn_fd_handler(int fd)
|
|||
}
|
||||
|
||||
leave:
|
||||
/* Verify if the connection just established. */
|
||||
if (unlikely(!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN | CO_FL_CONNECTED))))
|
||||
conn->flags |= CO_FL_CONNECTED;
|
||||
|
||||
/* The connection owner might want to be notified about failures to
|
||||
* complete the handshake. The callback may fail and cause the
|
||||
* connection to be destroyed, thus we must not use it anymore and
|
||||
|
|
|
|||
Loading…
Reference in a new issue