MINOR: connection: remove the double test on xprt_done_cb()

The conn_fd_handler used to have one possible call to this function to
notify about end of handshakes, and another one to notify about connection
setup or error. But given that we're now only performing wakeup calls
after connection validation, we don't need to keep two places to run
this test since the conditions do not change in between.

This patch merges the two tests into a single one and moves the
CO_FL_CONNECTED test appropriately as well so that it's called even
on the error path if needed.
This commit is contained in:
Willy Tarreau 2019-12-27 14:49:19 +01:00
parent b2a7ab08a8
commit cbcf77edb7

View File

@ -71,21 +71,6 @@ void conn_fd_handler(int fd)
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
* be destroyed, thus we must not use it anymore and should immediately
* leave instead. The caller must immediately unregister itself once
* called.
*/
if (!(conn->flags & CO_FL_HANDSHAKE) &&
conn->xprt_done_cb && conn->xprt_done_cb(conn) < 0)
return;
if (fd_send_ready(fd) && fd_send_active(fd)) {
/* force reporting of activity by clearing the previous flags :
* we'll have at least ERROR or CONNECTED at the end of an I/O,
@ -121,14 +106,20 @@ void conn_fd_handler(int fd)
}
leave:
/* The connection owner might want to be notified about failures to
* complete the handshake. The callback may fail and cause the
/* 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
* and/or handshake completeion. The callback may fail and cause the
* connection to be destroyed, thus we must not use it anymore and
* should immediately leave instead. The caller must immediately
* unregister itself once called.
*/
if (((conn->flags ^ flags) & CO_FL_NOTIFY_DONE) &&
conn->xprt_done_cb && conn->xprt_done_cb(conn) < 0)
if (unlikely(conn->xprt_done_cb) &&
(!(conn->flags & CO_FL_HANDSHAKE) ||
((conn->flags ^ flags) & CO_FL_NOTIFY_DONE)) &&
conn->xprt_done_cb(conn) < 0)
return;
/* The wake callback is normally used to notify the data layer about